This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-06
Channels
- # announcements (14)
- # babashka (12)
- # beginners (61)
- # biff (2)
- # calva (16)
- # clj-kondo (22)
- # cljdoc (7)
- # clojure (131)
- # clojure-europe (52)
- # clojure-losangeles (9)
- # clojure-norway (54)
- # clojure-spec (5)
- # clojure-uk (4)
- # clojurescript (18)
- # cursive (14)
- # datomic (19)
- # deps-new (14)
- # emacs (8)
- # events (7)
- # fulcro (6)
- # graphql (3)
- # hyperfiddle (42)
- # instaparse (5)
- # lsp (10)
- # malli (21)
- # nbb (1)
- # off-topic (3)
- # pathom (3)
- # polylith (7)
- # reagent (14)
- # releases (2)
So, Emacs's built in sh-script
mode defines keybindings with hard-coded prefix C-c
in sh-mode-map
[1]. This clobbers some of my C-c
-prefixed keybindings (e.g. counsel), when sh-script mode is active.
sh-script mode offers no way to specify a custom prefix (e.g. C-c s
).
- If I want my custom prefix on all the sh-mode-map bindings, then do I have to first keymap-unset
all the keys individually, and then custom-set them again, individually?
- And how do I prevent sh-mode-map from clobbering my counsel keybindings in the first place?
[1] sh-mode-map keybindings https://repo.or.cz/emacs.git/blob/HEAD:/lisp/progmodes/sh-script.el#l498
One way I do this is by setting the mode keymap to nil to unbind all the keybindings for the mode, and then selectively add new bindings to the functions that I actually use.
In your case, you can start with something like (setcdr sh-mode-map nil)
You may use the bind-key
package to create a new set of prefixed bindings like so:
(not tested)
(bind-keys :map sh-mode-map
:prefix "C-x"
:prefix-map custom-prefix-map
("(" . sh-function)
("C-w" . sh-while))
Thanks for the tip! I was coming around to the same realisation. Also, good to know about setcdr
. My elisp-fu is weak. Apropos (re)binding keys, use-package has me covered.

I don't know how to set bindings with a prefix without repetition within the use-package
macro. Let me know if you're able to figure it out.
not sure if it's helpful, but I have things like this in my setup which rebinds C-x C-c C-d
to run find-dired
(and I have a whole bunch of other keybindings in there too):
(define-prefix-command 'ed/C-x-C-c-prefix)
(global-set-key (kbd "C-x C-c") 'ed/C-x-C-c-prefix)
(define-key ed/C-x-C-c-prefix (kbd "C-d") 'find-dired)
cos who needs to quit emacs ever?> to set bindings with a prefix without repetition within the use-package
macro
I am under the impression :bind-keymap
is the way to do this: https://github.com/jwiegley/use-package#binding-to-keymaps