mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Add new 'nobackslashctrl' shell option; other minor editor tweaks
The following emacs editor 'feature' kept making me want to go back
to bash. I forget a backslash escape in a command somewhere. So I
go back to insert it. I type the \, then want to go forward. My
right arrow key, instead of moving the cursor, then replaces my
backslash with garbage. Why? The backslash escapes the following
control character at the editor level and inserts it literally.
The vi editor has a variant of this which is much less harmful. It
only works in insert mode and the backslash only escapes the next
kill or erase character.
In both editors, this feature is completely redundant with the
'stty lnext' character which is ^V by default -- and works better
as well because it also escapes ^C, ^J (linefeed) and ^M (Return).
[In fact, you could even issue 'stty lnext \\' and get a much more
consistent version of this feature on any shell. You have to type
two backslashes to enter one, but it won't kill your cursor keys.]
If it were up to me alone, I'd simply remove this misfeature from
both editors. However, it is long-standing documented behaviour.
It's in the 1995 book. Plus, POSIX specifies the vi variant of it.
So, this adds a shell option instead. It was quite trivial to do.
Now I can 'set --nobackslashctrl' in my ~/.kshrc. What a relief!
Note: To keep .kshrc compatibile with older ksh versions, use:
command set --nobackslashctrl 2>/dev/null
src/cmd/ksh93/include/shell.h,
src/cmd/ksh93/data/options.c:
- Add new SH_NOBACKSLCTRL/"nobackslashctrl" long-form option. The
"no" prefix shows it to the user as "backslashctrl" which is on
by default. This avoids unexpectedly changing historic behaviour.
src/cmd/ksh93/edit/emacs.c: ed_emacsread(),
src/cmd/ksh93/edit/vi.c: getline():
- Only set the flag for special backslash handling if
SH_NOBACKSLCTRL is off.
src/cmd/ksh93/sh.1,
src/cmd/ksh93/data/builtins.c:
- Document the new option (as "backslashctrl", on by default).
Other minor tweaks:
src/cmd/ksh93/edit/edit.c:
- ed_setup(): Add fallback #error if no tput method is set. This
should never be triggered; it's to catch future editing mistakes.
- escape(): cntl('\t') is nonsense as '\t' is already a control
character, so change this to just '\t'.
- xcommands(): Let's enable the ^X^D command for debugging
information on non-release builds.
src/cmd/ksh93/features/cmds:
- The tput feature tests assumed a functioning terminal in $TERM.
However, for all we know we might be compiling with no tty and
TERM=dumb. The tput commands won't work then. So set TERM=ansi
to use a standard default.
This commit is contained in:
parent
786a549e49
commit
24598fed7c
10 changed files with 51 additions and 7 deletions
|
|
@ -204,6 +204,10 @@ const char sh_set[] =
|
|||
"off. This can be repeated to enable/disable multiple options. "
|
||||
"The value of \aoption\a must be one of the following:]{"
|
||||
"[+allexport?Equivalent to \b-a\b.]"
|
||||
"[+backslashctrl?The backslash character \b\\\b escapes the "
|
||||
"next control character in the \bemacs\b built-in "
|
||||
"editor and the next \aerase\a or \akill\a character "
|
||||
"in the \bvi\b built-in editor. On by default.]"
|
||||
"[+bgnice?Runs background jobs at lower priorities.]"
|
||||
#if SHOPT_BRACEPAT
|
||||
"[+braceexpand?Equivalent to \b-B\b.] "
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
const Shtable_t shtab_options[] =
|
||||
{
|
||||
"allexport", SH_ALLEXPORT,
|
||||
"nobackslashctrl", SH_NOBACKSLCTRL,
|
||||
"bgnice", SH_BGNICE,
|
||||
#if SHOPT_BRACEPAT
|
||||
"braceexpand", SH_BRACEEXPAND,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue