| Age | Commit message (Collapse) | Author |
|
We cannot let readline sort the matches because it gets them after they are
quoted and the leading quote character messes up the ordering.
|
|
With this we can finally complete an open quoted word with an escaped quote
(e.g. 'it''s alive^I) without any issues!
It is really f!*#ing hard to bend readline to rc's simple quoting rules. Tons
of variables control a huge pile of code but every code path assumes just
enough of bash's quoting rules to render all these mechanisms unusable for rc.
Abusing *rl_completion_word_break_hook* is our only hope. Let us pray that this
keeps working.
|
|
Filename completion is not a special case anymore. The generated filenames are
quoted like the matches of the custom completion generators.
|
|
We only did this for external commands. Now function and variable names get
quoted too, if they contain a character that needs quoting.
|
|
We do not want to fall back to filename completion just because the
context-aware completion did not produce any matches.
|
|
An open quoted string was always completed as a filename. The type of
completion is now guessed based on the token preceding the opening quote in the
same way as it is done for unqoted words.
; 'fals -> ; 'false'
; echo $'hom -> ; echo $'home'
|
|
|
|
It is only needed for completing an open quoted string with an escaped quote:
'it''s alive
Unfortunately, readline will always treat the last quote character as the start
of the string so that unquote only gets called on "s alive".
|
|
Quote from the comment on the *bodge* mechanism:
(It would be better to persuade readline just to append the "/" as
it does for filename completion, but it's not clear to me if this is
possible.)
Readline has the *rl_completion_append_character* variable for exactly that.
|
|
|
|
Before appending a new line to the readline history, remove all prior lines in
the history, which are an exact duplicate of it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If an explicit complete function has only one match but is used directly after
the default tab completion, than the single match is shown instead of inserted.
The solution is resetting the 'rl_last_func' variable if it is set to
'rl_complete' when using an explicit complete function.
|
|
New commands:
- rc-complete-command, per default bound to "M-!"
- rc-complete-filename, "M-/"
- rc-complete-variable, "M-$"
These commands are useful, if one wants a specific type of completion which is
not performed by the context-senstive default one, e.g. filename completion at
the beginning of the line or command completion for the second word (after
sudo).
The readline code now also sets the application name to "rc", making it
possible to specify different bindings for these commands in ~/.inputrc:
$if rc
"\C-x\C-[": rc-complete-command
"\C-[\C-x": rc-complete-filename
"\C-x\C-v": rc-complete-variable
$endif
|
|
New completion entry functions for readline specific code:
- compl_var for variables
- compl_fn for functions
- compl_builtin for builtins
- compl_extcmd for external commands in path
- compl_command, which combines the last three
The first three are simple wrappers for compl_name, which iterates over a
typical rc table (an array of structs) yielding the name fields.
The appropriate completion entry function is chosen based on the
character/token that preceeds the word to complete: '$' for variable,
beginning of line or one of [`@|&(){;] for command. Otherwise the shell falls
back to readline's default completion, which it also does, if the chosen
completion entry function finds no match.
|
|
|
|
edit_catcher() performs a longjmp via rc_raise() to the matching setjmp in
doit(). The latter does the same as before, so that edit_alloc() gets called
again, but this time the installation of the signal handlers trashes the old
handlers saved in the last call. Once readline() returns normally to
edit_alloc() the wrong signal handlers get restored.
The simplified call hierarchy looks like this:
doit();
sigsetjmp();
edit_alloc();
oldint = sys_signal(SIGINT, edit_catcher);
readline();
SIGINT -> edit_catcher();
siglongjmp();
sys_signal(SIGINT, oldint);
Restoring the old signal handlers in edit_catcher() solves this.
|
|
This reverts commit 90de423084757db66041175b43a59b5ff630cb50.
|
|
|
|
|