[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-readline] keyseq to toggle insert-comment
From: |
Дилян Палаузов |
Subject: |
[Bug-readline] keyseq to toggle insert-comment |
Date: |
Sun, 7 May 2017 08:52:09 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
Hello,
insert-comment is effective, but not efficient, when it comes to remove
the comment. It is just faster to type C-a C-d C-j than M-- M-Shift-3
(as Shift-3 is #).
As hardly anybody has a need to prepend a # on a line, which already
starts with #, by using keyboard sequences, I propose to change the
behaviour of insert-comment to always toggle the comment-begin.
I thought I could achieve this locally, by putting something in
.inputrc, but I had no success.
The first problem was, that the documentation states, that e.g.
end-of-history is connected to M->, but dump-function shows that it is
in fact bound to "\e>". I do not find where this inconsistency is
reflected in the files.
Putting in .inputrc
"\C-x\C-m"; dump-macros
"\M-z": "test\n'
and pressing C-c C-r (re-read-init-file) C-x C-m (dump-macros) prints:
� outputs test\C-m
instead of
\M-z outputs test\C-m
Aha, let's fix bind.c:_rl_get_keyname() a little bit:
diff --git a/bind.c b/bind.c
index f1098c4..c5e72e5 100644
--- a/bind.c
+++ b/bind.c
@@ -2209,6 +2209,13 @@ _rl_get_keyname (key)
keyname[i++] = '-';
c = _rl_to_lower (UNCTRL (c));
}
+ if (META_CHAR (c))
+ {
+ keyname[i++] = '\\';
+ keyname[i++] = 'M';
+ keyname[i++] = '-';
+ c = UNMETA (c);
+ }
/* XXX experimental code. Turn the characters that are not ASCII or
ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
And now:
"\C-\M-z" is rendered as "\e\C-z";
"\C-\ez" is rendered as "\C-\\ez";
"\C-\M-\ez" is rendered as "\e\C-\\ez";
"\C-\e\M-z" is rendered as "\C-\\e\M-z";
"\M-\e\C-z" is rendered as "\M-\\e\C-z";
"\M-\C-\ez" is rendered as "\M-ez";
"\e\M-z" is rendered as "\e\M-z"
"\e\C-z" is rendered as "\e\C-z"
"\M-\ez" is rendered as "\M-\\ez",
"\e\C-\M-z" is rendered as "\e\e\C-z" and
"\M-\C-z", "\e\M-\C-z" produce unprintable text.
The next challenge is that to my understanding of the documentation, a
key binding/key sequence can be connected to only one function, but I
want to bind it to "toggle insert-comment"/universal argument
insert-comment, which are two functions. I gave here up.
I use libreadlie-7.0.3.
I centrifuged libreadline through the clang 4.0 static analyzer
(scan-build ./configure && scan-build make) and here is the result:
https://mail.aegee.org/dpa/scan-build-readline-6c32f81cd66/
Please note, that the information is only about what gets actually
compiled, code disabled by #if .. #endif is not considered (e.g. when
determining whether a variable assignment is useless). There are
probably some false-positives. But it states correctly e.g. that in
text.c:870 or histfile.c there are superfluous assignments.
Consider this as information, I do not pretend there are any bugs found
by the static analyzer.
Regards
Дилян
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-readline] keyseq to toggle insert-comment,
Дилян Палаузов <=