Making ^J and ^H work in / (search)
Dmitry Alexandrov
321942 at gmail.com
Thu Jun 30 16:36:59 CEST 2016
Alexander Berntsen <alexander at plaimi.net> writes:
> On 28/06/16 16:01, Dmitry Alexandrov wrote:
>> I guess, you actually want to make ‘C-h’ equal to ‘DEL’ and ‘C-j’ to
>> ‘RET’ *everywhere*, not just in isearch (there is no any evil-mode’s
>> search, as far I know), helm, etc. Nothing is easier:
>>
>> (define-key key-translation-map (kbd "C-h") (kbd "DEL"))
>> (define-key key-translation-map (kbd "C-j") (kbd "RET"))
>>
>> I would not reject ‘C-j’ though, it is useful sometimes to have two
>> returns: a ‘smart’ one and a ‘dumb’ one.
>
> I don't want DEL, I want backspace.
Do you have ‘<backspace>’ that is bound somewhere else than ‘DEL’? (See
‘<f1> k <backspace>’.)
> So I changed it to (global-set-key (kbd "C-h") (kbd "<backspace>"))
> instead of delete-backwards-char. But it still doesn't work when
> searching.
Is there is any reason why you believe that this should work? I did not
suggest you to do anything like this.
> '/ab^J' will bring up search, and add 'ab' followed by literally the
> characters '^' and 'J'.
No, it’s followed by literally the character ‘^J’ (this is one character
— ‘linefeed’ aka ‘\n’ is C notation).
By the way, this is a good illustration on why one should not use ‘^J’
as notation for ‘C-j’, ‘^H’ for ‘C-h’, etc — cases when ‘[(control
<something>)]’ inserts itself are extremely rare, mostly keys with
control modifier are bound to some command.
> '/ab^H' will bring up search, add 'ab' to the
> query, and then close it.
>
> The problem in helm is different. If I bring up helm using helm-M-x,
> using ^J or ^H will not work for different reasons. ^J because it is
> bound to something else, and ^H because it's not bound to anything
> (i.e. ^H^H will print "C-h C-h is undefined").
More information about the implementations-list
mailing list