summaryrefslogtreecommitdiffstats
path: root/usr.bin/mg/file.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add dired-find-alternate-file.lum2016-01-021-5/+13
|
* Fix opening dired from the command line. Incorrect cursor placementlum2015-10-291-3/+1
| | | | | and make the error more useful when there is a problem opening a directory. Reported by and ok jasper@
* Check to see if the file to be opened is a directory as soon as islum2015-09-291-5/+27
| | | | | | | feasible. Currently, mg does this check much later on which means some functions (e.g showbuffer()) are called multiple times. This fixes the location of the cursor when opening a directory using filevisit, findvisitalt and poptofile. ok jasper@
* We really don't need ttydef.h -- it is like sysdef.h -- once useful becausebcallah2015-03-251-5/+2
| | | | | | | | | | | supported a lot of systems and nothing was standardized. But now it only 4 defines. Move those defines into def.h since ttydef.h is only sourced in def.h While here, MAKEBACKUP has the same #ifdef dance that LINENOMODE had. Set it directly to TRUE and remove the #ifdef block. ok florian@
* Clean up the includes in mg.bcallah2015-03-191-4/+10
| | | | | | | | | | This does the following: Moves all POSIX headers from sysdef.h into the individual .c files so that each file now only includes what it needs. All headers are properly sorted. Moves the remainder of sysdef.h to other files (mostly def.h) and deletes sysdef.h now that it's no longer contains anything. Tweak a comment that references sysdef.h so that it no longer does that. ok florian@
* Revert 1.93, it breaks permission checks.florian2014-04-091-14/+16
| | | | "go for it" deraadt@
* When finding a file in a non-existant directory:lum2014-04-031-4/+4
| | | | | | | C-x C-f ~/no/dir/here/fn offer to make the directory by pressing 'y', instead of suggesting the make-directory command. ok jasper@
* Tidy up. No functional change.lum2014-03-311-16/+14
|
* Add some missing dobeeps.lum2014-03-201-2/+10
| | | | ok florian@
* Check if buffer is to be saved as a directory.lum2014-03-141-1/+6
| | | | ok florian@
* Move findbuffer() to buffer.c.lum2013-12-231-28/+1
| | | | ok florian@
* Fix previous; ENOCOFFEE.florian2013-10-221-4/+3
| | | | | Move xdirname call into the right if block, pointed out by Ulrich Mueller.
* Our man page states that it's not portable to rely on dirname(3) notflorian2013-10-221-10/+10
| | | | | | | | | | | | | | modifying the contents of the passed string. Replace dirname(3) with mg's xdirname portability helper function (a slightly different fix than Gentoo's). Report and initial analysis by Marien Zwart in Gentoo bug #487758 via Han Boetes (hboetes _AT_ gmail). Gentoo bugfix by Ulrich Mueller (ulm _AT_ gentoo). testing on glibc / input Ulrich Mueller; testing on glibc Han Boetes. Thanks! OK jasper@
* Record when the buffer was saved in the undo history. The bufferflorian2013-03-251-1/+5
| | | | | | will be marked unchanged at the correct point when stepping through the undo history. OK jasper@
* Grammar nits.lum2013-02-101-2/+2
|
* - add 'make-directory' (not bound to any shortcut).jasper2012-11-271-3/+4
| | | | | feedback from florian@ lum@ ok florian@
* oops. need to reset errno. Otherwise we can't save a new file in alum2012-08-301-1/+2
| | | | directory where permissions are ok.
* This diff allows the user to decide what to do with buffers thatlum2012-08-301-2/+17
| | | | | | | | | experience write errors during C-x C-c (exiting mg). Emacs stops the exiting process when it encounters problem buffers and lets the user decide what to do, currently mg continues exiting and the contents of these buffers are lost. This diff bring mg more into line with emacs. Review and observations from Sunil Nimmagadda.
* Make mg behave more like emacs with regards to opening a new buffer:lum2012-08-281-6/+24
| | | | | | | | | 1. If parent directory is read-only, make buffer read-only. 2. If parent doesn't exist; give user a message and create buffer as readable. Reviewed by Sunil Nimmagadda. ok jasper@
* Removing this 'if' statement allows dired buffers to not have theirlum2012-06-181-7/+5
| | | | | | | | | | | | | forward and backward line pointers pointing to the same line, causing mg to spin when asked to split the window. This happens if a directory is opened via the command line sequentially first, and other windows need to opened afterwards (for other files). Since the information within this 'if' statement is updated later for files and directories I can see no problem with removing this. No regressions viewable either. Problem reported by and diff tested by jasper@
* Remove static FILE pointer used for handling files in fileio.c. Passlum2012-05-251-12/+16
| | | | | | | by reference instead. This allows the mg startup file to open other files without unexpected things happening. Discussed with Sunil Nimmagadda.
* Allow throwaway buffers to be saved via C-c s. This difflum2012-05-101-2/+5
| | | | | | | does not change the behaviour with regards to mg not asking to save throwaway buffers when exiting. Reviewed by Sunil Nimmagadda.
* Fix a bug in writeout() where the stats of the wrong filelum2012-05-081-2/+4
| | | | | | were given to a buffer being written. Reviewed by Sunil Nimmagadda.
* When writing a file via 'C-x C-w', ask user if they want to overwrite anlum2012-04-111-2/+14
| | | | | | existing file. This mimics emacs behaviour. Reviewed by Sunil Nimmagadda.
* On a file write fail:lum2011-08-311-4/+6
| | | | | | | 1. return an error value 2. show an error message From Loganaden Velvindron with suggestion from millert@
* Wrap basename,dirname with xbasename, xdirname funtions,kjell2011-01-231-22/+37
| | | | | | which have fewer special cases, and use the strlcpy/strlcat src/dst/buffer len semantic. More portable to boot. Discussion and feedback from Henri Kemppainen
* It volates style(9), but in mg, #include"def.h" goes first. 'twas the way it was built. no binary change here. confirmed by lum@, tested by Henri Kemppainenkjell2011-01-211-3/+3
|
* augbname immediately does a basename. No need to do it in thekjell2011-01-181-2/+2
| | | | caller, too. ok lum@
* From the Loganaden Velvindron:kjell2010-06-261-5/+7
| | | | | | | | | Make dired more sane (and emacslike): * Position cursor at first filename after .. * Don't reposition cursor on reopening * Check for permission before attempting to open directory I took forever to get this in. Thanks, Logan for being patient!
* Add the notion of an "ephemeral" popup, so we can flag a windowkjell2009-06-041-2/+2
| | | | | | | | | | | for destruction at a later date. (in the process, add a window flag field) This fixes an issue noted by maja: namely, the *completion* window that pops up when you try to complete a filename on buffer load would destroy any second window that you happened to have open. ok maja@
* Rename w_flag to w_rflag. This is not a general purposekjell2009-06-041-3/+3
| | | | | | | flag: it is for redisplay options only. I need an additional all-purpose flag, so renaming removes the desire to wrongly overload the existing one. Turdshine. No functional chage.
* Expose the undo commands as proper mg functions.kjell2008-09-151-6/+6
| | | | | This should have no functional change on undo, but it does facilitate testing undo behavior.
* Enable dirty buffer detection in mg.kjell2008-09-151-2/+11
| | | | | | | | Emulate the emacs behavior: after suspend/resume, buffer switch, or at save time, warn (prompt) the user if the file has been modified on disk in the interim. This has already saved my butt numerous times. ok phessler
* Don't free the buffer name until after you call adjustname.kjell2008-06-181-2/+2
| | | | | Fixes a segfault that occurs when you write a file to an alternate name. Introduced by yours truly in 20060406. how did it last this long?
* Fix debian bug #432656kjell2008-06-131-4/+28
| | | | | | | 'Prints root directory as "//" instead of "/" for root files.' Issue was with dirname, which strips the trailing slash, except when given "/". Wrap it in a cover function to fix. Also helps with portability to data-munging dirname glibc.
* Reset startrow when opening multiple files. Spotted by matthieu@pyr2008-03-211-2/+4
| | | | ok, kjell@, matthieu@
* Fix a bug where inserting a file resulted in an incorrectkjell2006-12-241-17/+25
| | | | | | | | | line-number count for a buffer (M-X insert-file, M-> to reproduce). While here, fix a number of bugs with incorrect line numbers after swap point-and-mark Originally reported via debian's bug tracking system. Fix tested by Han Boetes and Deanna Phillips.
* Fix a needless inversion of flag names; i.e. change them from thekjell2006-11-171-2/+4
| | | | | | | | negative to the positive. undo_boundary_enable(TRUE) makes a LOT more sense than undo_no_boundary(FALSE). While here, whack a global, and fix a bug noted by otto: undoing a file insertion sometimes left stray characters around. ok beck@, otto@
* Add bfirstlp(), blastlp() macros, returning the first and last lineskjell2006-07-251-2/+2
| | | | | | of a buffer respectively. Removes an ugly construction than necessitated "go to first line"-type comments throughout the code. No binary change
* Rename the header line of a buffer to b_headp, from the remarkablykjell2006-07-251-5/+5
| | | | unintuitive b_linep. No binary change.
* Introduce a 'MODIFIED' boundary type for undo records.kjell2006-07-081-1/+2
| | | | | | | This allows undo to clear the modified flag when undo-ing all the way from a loaded buffer. Originally whipped up at c2k6 after proddings from beck. jason@ ok.
* Display line number in the mg statusbar. Yes, it seems like a fuglykjell2006-06-011-7/+10
| | | | | | | | | | way to do it, but all the clever and pretty ways utterly failed. Basic use seems fine. We'll turdshine the special cases later. If it bothers you, use M-x line-number-mode, or put same in your ~/.mg file to disable. ok cloder, jason
* make // /~ path rewriting optional in adjustname() and use it everywherejason2006-06-011-6/+6
| | | | except for the command line specified files. ok kjell,cloder
* Initialize current window, and clear the readonly flag earlier in filekjell2006-06-011-11/+12
| | | | | read process. This allows code in the autoexec path (i.e. ~/.mg) to operate on the buffer, making ~/.mg files much more useful.
* find-file-other-window and find-buffer-other-window should splitkjell2006-06-011-1/+3
| | | | | the window if you ask for whatever file you are currently visiting. pointed out, ok beck@
* Make Window Flags more mnemonic (and less dumb); i.e.kjell2006-05-281-4/+4
| | | | | | WFHARD -> WFFULL (Redraw full window) WFFORCE -> WFFRAME (Reframe window). No binary change
* Make buffers store their own working directory. This makes things likekjell2006-05-021-29/+30
| | | | | | grep, compile, lint work as expected (act on current buffer's cwd). Display this path when opening or replacing a file, rather than relying on the user to guess, or remember.
* Fix a bug whereby a written buffer (^X^W) would not have the correctkjell2006-04-061-18/+13
| | | | | trailing buffer number appended (e.g. "file<2>") in case an existing buffer shared its basename().
* few more int that can become a size_tderaadt2006-04-031-4/+5
|
* lint love; ok kjellderaadt2006-04-031-2/+2
|