Making ^J and ^H work in / (search)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 I have the following: (global-set-key (kbd "C-h") 'delete-backward-char) (global-set-key (kbd "C-j") (kbd "RET")) How do I make this work in evil-mode's / (search)? Bonus points if anyone has the scoop on making it work in helm as well. - -- Alexander [email protected] https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJXcjQqAAoJENQqWdRUGk8BUQoP/AyqQCaN/d+4HJXIVt7Gz15f FqL/Qx5EjZCgaq4QMp+b9QyP93wJR9XbVxKCU54j77QPuoOCEdlj3rTAVr04/fD9 aAQ0+HKFw62ADBHx1Gt7vq0pPEbSWGyOaMOyVr630km4wxliTdyTliQLqIyYKTvI Yl6wZCeFUUl0yv+zIzoXEP8HvZY6LAHWnQU0JdSImkIrgU0xJjaCuiuPL3qyMyTf XPhw8TpQ7tbxMiMDyoS58UdU3Eo3kzXlR8+8HNRaHGX/f23JA1NVb9Gr88hQMWEY jOCwhg0MrA2NPdefXDXpLsyTf8La1uQdkXigXN+7+R43lB7T95UngSomNo0pzlDF 0nhyUxj9SrIa/hGRnnk4g7ty5/t7R7Dr0pM9nvO6IB9H3b1NT3Q4APwCUeDdJqbd 4KTo9j2v0EYB+DT6+88DjqwtD5BQZTaBK6vTh3yZCajoV9NlkYqICae9t8brc1/Z l1jynQ6lAi9sC1orv0k3SGWducwR5l/Q65tx1lc8/3/3ou99gj0Pe6limW/DDXbs 4G0KHN9kzqGlF7EnDM4npbPNjdusMDzHuv0FWIiq5DS+BMv74329oE0UpllTJFcp M5zKWpiFukkO9jANp2IAlHflnJ8H6T3S8qElcoGuM72/2g3aJ2kaWZC0wephyUD2 HhyNIW+JF/7QK9l05vFm =vyG5 -----END PGP SIGNATURE-----
Alexander Berntsen <[email protected]> writes:
I have the following:
(global-set-key (kbd "C-h") 'delete-backward-char) (global-set-key (kbd "C-j") (kbd "RET"))
How do I make this work in evil-mode's / (search)?
Bonus points if anyone has the scoop on making it work in helm as well.
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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 28/06/16 16:01, Dmitry Alexandrov wrote:
I guess, you actually want to make ‘C-h’ equal to ‘DEL’ I don't want DEL, I want 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.
'/ab^J' will bring up search, and add 'ab' followed by literally the characters '^' and 'J'. '/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"). - -- Alexander [email protected] https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJXdRGKAAoJENQqWdRUGk8B2iQQAPLlrJ2qr0yGXcCFhwfQgjD5 mkj9Pp0sf4k6Apf5hHdZsTvVI2Dkk7kEHjPUfR8rRK4THpFIxf0hd6MQyyZhfVj4 LAeHRwwdRims8jBS/54JAJHG3ANnfcfH4V7qy8zNYTIDz3/cNXZYI0Y8xG2gjkX+ scqSkNFhsU5Vxjmh26t0HwuynTu+P4uQ83EOLgAEiQxtFz3vQ5nwLF+uZMDw0WLv KFsSpGV5u1GZaRR4egKiXRZjR7ABpO3XCMbfnuJdWFYzo95h2ic1jUukdID8poGw WEakM0N8GKUpERcnSkY+xsXQ7y/kgGETK7ufpXd35KUwQWpd5UoyffdtfHxjGh3I S5FmYoi2amaWGWj1quvDEubyAl+Mkafdo6pM2Os6B0A7cz4N0u+0qEO2ANislLJK paBnyS9ExbOMUxR3VcyHcz0pOimi5bDBN2WAQ904yGc0p+BODd4iOzFc4+RVy9Qq Ra8GIboZ8pBNIhPu94MoZfLjuu5G4Qky72CjBjI0z2yyFBspGOiAS2MdYPqFpka9 AtCyixFlx84SZTe4c0MEfNU0qNuU8nWtZO/hJqxyGYxcz67u2PbwTFQvJctf8qqI zF8Oy79PxWRAJwO/jkeXNLeWHLMZPJFtc5W192xRpP978I9HXGW4HWdEnhxslDi/ skS3IR6o8YpS0DTkfMmT =NLbj -----END PGP SIGNATURE-----
Alexander Berntsen <[email protected]> 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").
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 30/06/16 16:36, Dmitry Alexandrov wrote:
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. I confused what kbd "DEL" did with what the DEL key does. Using kbd "DEL" achieves the same as kbd "<backspace", as far as I can tell.
'/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). Sorry, I meant visually. It is indeed literally the character '^J'.
In the end though, your suggestion unfortunately doesn't solve anything. - -- Alexander [email protected] https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJXdXm2AAoJENQqWdRUGk8BNxgQAPGGWFtBWYfW3ectg39XBwJ6 vU/95KQ5SPIvDQvVdMq64d4j/K4jV/I/d4nRl5gt4V4ZuxF5gOfZIC5bNkTVqJAU cLI9V0VKUAZogfIPoUVEk/t4XPypFoyS8Yy/FyKCAv3dqL+qqgnJx/VNBaArjGqg TDsVuddpj/pSkDHunIfjzd+Bc8EtjCu8vFmOLBHti7utO/5/jtLz+UQdLDA13N+M WUmwjVOvyeNJzVQYn9G68MFeRW/4vkdUaZoAKcMeuW2WE90RYJ5BFvOQrHafEGNt 7z9fOrv8rRr19ddxOrPxOoh+qSD4z3rbEov3ZPMovLKAJ5wNF3ARMCWgnY7QKh51 quSy88FafLxUDcXVgCIReS8t53cLtKXmNo3yBF1mvwX8Oo3l6/x37RZD7gncdI22 uisB8MrKjBW+0nPs0wbMuKKrlqnMyrUASpSNCItzuM3cM4zvJfsgpwztCs26IRVo 34M3NGSN2ZCTgySyJQ7gOpZBq4owcV09KN7Sv77J1T8fwcWBc0Rnmbf1dVK+gidP UQpHx8+5MM8dJrd2xRO/xyvwjdDKAlFTg/88LWgFPZQfCr5xxgPpOPBKc/QMOA1g t2sKDPT8F9q2S6dozYcuxaxMoFqbnts47SJQVVjemPaGpfRhPoOREWHTXX87q9lv wuVHbrqzN7l4lPPCeLsf =hC6x -----END PGP SIGNATURE-----
Alexander Berntsen <[email protected]> writes:
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.
I confused what kbd "DEL" did with what the DEL key does. Using kbd "DEL" achieves the same as kbd "<backspace", as far as I can tell.
'/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).
Sorry, I meant visually. It is indeed literally the character '^J'.
In the end though, your suggestion unfortunately doesn't solve anything.
Sorry, I’ve missed *when* did you try this suggestion (to use ‘key-translation-map’). I’ve re-read our conversation (restored in quotes above) — and all you said is that you had merely ingored it and tried something else with ‘global-map’ (‘global-set-key’).
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 30/06/16 23:03, Dmitry Alexandrov wrote:
Sorry, I’ve missed *when* did you try this suggestion (to use ‘key-translation-map’). This is what I get for answering email in a hurry. (Twice!)
Your suggestion works perfectly. Thank you. And double thank you for your patience in pointing out that I misread. (Twice!) - -- Alexander [email protected] https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJXdYpfAAoJENQqWdRUGk8BQxIQAOaddt9noHlZlwgNECYzRh6z AUDIZs9cktHLT/Z85JCnffsbTqn4QsGmwll9c3rZk1gUcyAP2kPe2bMffFBs0hsC g6SZjRYdMkWUzEqmcl/kZ4yCk4xru50ra00UGbgQXBEXRKRghDKHmNWYitflq8kK tNLfAN3zP78LWZXRpYm1gIfw1BvMPAvFopwmCShOcbZyC+ZZM46hM3L82WBhZYdp JkkL25lk4+Zzm0aqxTwE3WsnbRTYtQ7sQHiJBFfXck5jOBjgrrI/OWcLwBDlRW4N skLSDiBiYCjEiIfYkoXezaPBoUAo07hyQeLl/8m9t36Xbt/bTcNzAvEAm+PX+7HJ f6f4XDXTZ+U5U5fRq2u/ZM9vpQtOPOJec0eSdhjcX9hoxXy23zaKYcyr1+x6RUdP IAu2MPyNQ1CzCqY2yVvvSZvZ8c+p89DjcdmS2B8GFLfS1DEkUeHx+Lg17t54ZLq3 S0Quhfgr93IAf6MB4eOxZU8CLo8C6czY7tjRzyMEV3A+xDVZzdkUyMFgsURRVZcB Fvsxb87KC39hMkS2xsrgyp+QZvh/IXrP+Ny5ApQ2u/PnMwZmStW9MMDz44/fVa3B NMTNFVXEaZVbB2rMYexbQJnyFxvwvEF+dFgppL9qI+W07LefPkkHBu38i9G2QCjA LV7FQP4xui7weWL8a3Cg =gcYO -----END PGP SIGNATURE-----
Alexander Berntsen <[email protected]> writes:
On 30/06/16 23:03, Dmitry Alexandrov wrote:
Sorry, I’ve missed *when* did you try this suggestion (to use ‘key-translation-map’).
This is what I get for answering email in a hurry. (Twice!)
Your suggestion works perfectly. Thank you. And double thank you for your patience in pointing out that I misread. (Twice!)
You are welcome. :-) Now about flies in the ointment. Being a more low-level thing than ‘global-map’, ‘key-translation-map’ acts not on a whole key sequence, but rather on every single key chord. I. e. it affects not only ‘C-h’ and ‘C-j’ on their own, but also, for instance, ‘C-x C-h’ or ‘C-c C-j’ whatever and wherever they mean. There is should not be any practical problem with ‘C-h’, since it almost everywhere stands for ‘help’ and has ‘<f1>’ as a synonym. But if you’ll stick to ‘C-j’ mapped to ‘C-m’ / ‘RET’, you have to sort it out somehow. The laziest way is just to use ‘C-S-j’ (‘S’ stands for shift) whenever the ‘real’ ‘C-j’ is required. But I have to repeat that I would not consider giving up ‘C-j’ even on its own a good idea — it is very useful to have ‘dumb’ and ‘smart’ return keys, at least for any sort of auto-completion — smart one selects the most relevant completion, while dumb one applies exactly what you’ve typed. (Which chord is dumb and which is smart depends on personal preference — there is no consistency through GNU Emacs packages, for example in ‘icomplete’ ‘C-j’ is smart by default and ‘C-m’ / ‘RET’ is dumb, while in ‘ido’ — exactly the way around.)
participants (2)
-
Alexander Berntsen -
Dmitry Alexandrov