aboutsummaryrefslogtreecommitdiff
path: root/sam.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-14vis: add new :set savemethod auto|atomic|inplace optionMarc André Tanner1-2/+9
Specifies how the current file should be saved, `atomic` which uses rename(2) to atomically replace the file, `inplace` which truncates the file and then rewrites it or `auto` which tries the former before falling back to the latter. The rename method fails for symlinks, hardlinks, in case of insufficient directory permissions or when either the file owner, group, POSIX ACL or SELinux labels can not be restored. The option defaults to `auto`.
2016-12-14text: expose text save method to calling codeMarc André Tanner1-1/+1
There are cases where it is useful to specify how the file should be saved.
2016-12-03vis: improve :set option number parsingMarc André Tanner1-2/+1
Only accept numbers in range [0, INT_MAX]. Reject trailing garbage, where before something like `:set cc 50NaN` worked it will now cause an error. Close #418
2016-11-28sam: introduce `m as an address refering to mark mMarc André Tanner1-0/+15
2016-11-27sam: stricter command parsingMarc André Tanner1-5/+20
Properly detect unbalanced curly braces and spurious output at the end of a group.
2016-11-25vis: fix I/O redirection bugs, cleanup vis_pipeMarc André Tanner1-4/+4
The `:!` command did redirect stdout to a pipe which was used by `vis-menu` to return the selected entry. However, this breaks other interactive commands such as `:!/bin/sh` where command output was never displayed. Instead we modified `vis-menu` to re-open /dev/tty for its user interface which makes it work as a regular filter `:|` This patch also obsoletes the interactive flag previously passed to the vis_pipe function. Interactive mode is instead enabled by piping an invalid range.
2016-11-22vis: add `:set escdelay nn` optionMarc André Tanner1-0/+6
Make the delay used to distinguish between an <Escape> key and other terminal escape sequences such as for the Meta key run time configurable. The value is given in miliseconds and defaults to 50ms. Notice that terminal multiplexers like dvtm or tmux might also induce some delay which has to be configured independently.
2016-11-22vis: populate :set option map at startupMarc André Tanner1-0/+8
2016-11-22vis-lua: also emit save events when writing to stdoutMarc André Tanner1-0/+6
The path argument will be nil.
2016-11-22vis-lua: introduce pre-save hookMarc André Tanner1-0/+5
The first argument is the file object while the second argument denotes the full path to which it will be written. Path might be `nil` if the file is going to be written to stdout. The Lua function is expected to return a boolean value indicating whether the write operation should proceed or be aborted.
2016-11-22vis-lua: pass path as second argument to file_save_post event hookMarc André Tanner1-1/+1
The passed path can be different from file.name for instance when opening a file `a` and then doing `:w b` where file.name will be the former and path the latter.
2016-11-21vis-lua: rename file_save event to file_save_postMarc André Tanner1-1/+1
Indicating that the event is triggered *after* a successfull write.
2016-11-21sam: change default addresses used for commands in normal modeMarc André Tanner1-11/+12
Except for special commands like `w` and `wq` treat the cursor as an implicit one character selection to which the command is applied.
2016-11-19sam: change default address of "s" command to current lineMarc André Tanner1-1/+1
2016-11-16sam: use default shell command for <, >, | and ! when applicapleMarc André Tanner1-3/+9
If the shell command is omitted, the last shell command (of any type) is substituted. The most recently used shell command is stored in a new register currently named `!`.
2016-11-16sam: support an empty regex as an alias for the most recently used oneMarc André Tanner1-3/+2
As in sam if an empty regex // is provided we substitute in the most recently used one. 0/regexp/// Will match the second occurrence in the fie.
2016-11-15sam: make `:w` and `:wq` honor their given rangeMarc André Tanner1-17/+27
As in visual mode write commands have to be forced with ! if the changes are destructive i.e. only parts of the file are written.
2016-11-15sam: `e`, `q`, `X`, `Y`, `!` and all vi commands should not take addressesMarc André Tanner1-23/+23
2016-11-15sam: reformat command definition block to avoid overly long namesMarc André Tanner1-50/+131
No functional changes.
2016-11-15vis: overhaul and unify event generation codeMarc André Tanner1-2/+1
Add another layer of indirection, move actual event generation code to a dedicated function.
2016-11-15vis: generalize special stdin handlingMarc André Tanner1-2/+2
In preparation to move argument parsing code out of vis.c.
2016-11-11vis: add `:set shell` optionMarc André Tanner1-0/+6
2016-11-11sam: fix range for line zeroMarc André Tanner1-0/+2
:0 < echo "Should be inserted at the start of the file" :1 < echo "Should replace the first line"
2016-11-10vis: split `:set show <option>` into separate optionsMarc André Tanner1-5/+17
It was the only command option which needed `=` to assign a value to. This unifies the argument parsing logic and adds the possibility to specify a per-option help text. You might want to adapt your visrc.lua configuration accordingly.
2016-11-10vis: add help texts for :set option valuesMarc André Tanner1-11/+56
2016-11-08sam: fix default value handling of +/- addressesMarc André Tanner1-3/+6
We need to distinguish between an explicit given zero and an omitted value which should default to 1. This should fix the following constructs which rounds up/down an existing selection to whole lines -0,+0 and -0+,+0-
2016-11-08sam: dispose primary cursor at end of groupMarc André Tanner1-0/+2
Something like :{ x/pattern/ } should not leave the original cursor around.
2016-11-04sam: y should also loop over empty trailing matchesMarc André Tanner1-1/+5
The following x/example/ y/e/ i/-/ should produce `-e-xample-` where before it would wrongly result in `-e-xample`.
2016-11-02sam: improve cursor positioning after command executionMarc André Tanner1-7/+28
Previously something like :x/pattern :c/replacement would cause all cursors to disappear because the location they were placed on was deleted beneath them.
2016-11-02sam: fix default command handling at end of a groupMarc André Tanner1-1/+1
Something like :{ x/pattern/ } should select all occurrences of pattern.
2016-11-02sam: ignore white space between commands of a groupMarc André Tanner1-2/+1
2016-11-02sam: fix command name parsingMarc André Tanner1-2/+2
Any white space should terminate the command name. In particular multi-line commands as part of a group were not handled correctly.
2016-11-02sam: improve escape parsing logicMarc André Tanner1-22/+16
\\ should not be treated specially when parsing regular expressions.
2016-10-05sam: show error message on failed writeChristian Hesse1-2/+4
2016-09-30sam: simplify :r command implementaionMarc André Tanner1-13/+6
Avoid intermediate shell.
2016-09-29sam: consistent argument handling for :r, :w, :e commandsMarc André Tanner1-23/+17
:e without any argument can be used to reload the file from disk whereas before a "Filename expected" error would be displayed.
2016-09-27sam: allow non-latin command namesMarc André Tanner1-1/+1
Close #387
2016-09-25sam: change license headerMarc André Tanner1-3/+14
We use an adapted variant of sam's structural regular expression based command language. The initial implementation was partially based upon the following functions from sam / acme: * parse.h / edit.h (struct definitions) * cmd.c / edit.c (functions parsecmd, simpleaddr, compoundaddr) * xec.c / ecmd.c (cmdexec) * address.c / addr.c (address) It turns out the relevant code can be traced back to the initial X11 port of sam which is distributed under an ISC-like license instead of the Lucent Public License Version 1.02 used for Plan 9, plan9port and 9base. http://www.netlib.org/research/ http://www.netlib.org/research/sam.shar Hence we switch to the simpler license variant. Close #238
2016-09-19vis: also list :set options in :help outputMarc André Tanner1-0/+44
The help formatting could probably be improved, short single line help texts are still missing. Patches welcome. Close #283
2016-09-19vis: add rudimentary builtin help for :-commandsMarc André Tanner1-49/+49
2016-09-19vis: do not invoke file save event for internal filesMarc André Tanner1-1/+1
2016-08-07sam: do not change cursor position after :! commandMarc André Tanner1-1/+1
Fixes #364
2016-08-07sam: improve quoted argument parsingMarc André Tanner1-33/+28
Handling of unbalanced quotes could probably still be improved. Closes #344
2016-05-29sam: use more suitable error message if no command is givenMarc André Tanner1-1/+3
2016-05-26vis: use normalized absolute file names as internal representationMarc André Tanner1-4/+2
Try to display a shorthand version in the status bar, this currently only works for files below the current working directory of the editor process.
2016-05-18vis: add an interactive mode to vis_pipe{,_collect}(...)Marc André Tanner1-2/+2
Previously the interactive mode was implicitly enabled by passing an invalid range. However for some use cases (e.g. completion) we need to be able to pipe a given text range to an external process without also redirecting stderr (which is used to draw the slmenu interface on top of vis).
2016-05-14vis: allow :commands with a hyphen in the nameMarc André Tanner1-1/+1
This fixes the argument parsing for the :{un,}map-window commands.
2016-05-05sam: avoid taking snapshots within the filter command implementationMarc André Tanner1-18/+1
This has the effect that multiple filter commands can be undone together.
2016-04-29vis: do not crash when processing :-commands and no window is activeMarc André Tanner1-3/+29
This is needed to make the vis.event.start Lua callback useful, setting global options should be possible even if no windows exist yet. The :set command options should probably be cleaned up further, some of them apply only to the currently active window while others have a global effect.
2016-04-21vis: add infrastructure to register custom :-commandsMarc André Tanner1-1/+5