helpful
helpful copied to clipboard
helpful-mode-map with rebinds?
hi, helpful is very nice... but... 😉
a helpful-mode
to enable rebindings of the functions provided by helpful
would be... helpful!
inspiration: this would be similar to what counsel-mode
does.
Sorry, I don't see what counsel-mode
has to do with keyboard bindings. Could you describe how you'd expect it to work?
sure, i'll explain.
i think helpful-*
commands can replace built-in describe-function
and describe-variable
– i assume that's even the point of this package. ;)
so, for instance, i can do this to rebind the default bindings to helpful
replacements:
(use-package helpful
:general
("C-h f" 'helpful-function)
("C-h v" 'helpful-variable))
however, helpful
should know better and could provide a helpful-mode
to rebind keys in the keymap for that minor mode. this would allow me to use this to achieve the same:
(use-package helpful
:config
(helpful-mode)
the reason i mentioned counsel-mode
is that it uses this pattern to remap key bindings from built-ins to commands provided by that package. fyi, here's what it looks like in counsel
(defvar counsel-mode-map
(let ((map (make-sparse-keymap)))
(dolist (binding
'((execute-extended-command . counsel-M-x)
(describe-bindings . counsel-descbinds)
(describe-function . counsel-describe-function)
(describe-variable . counsel-describe-variable)
(describe-face . counsel-describe-face)
(list-faces-display . counsel-faces)
(find-file . counsel-find-file)
(find-library . counsel-find-library)
(imenu . counsel-imenu)
(load-library . counsel-load-library)
(load-theme . counsel-load-theme)
(yank-pop . counsel-yank-pop)
(info-lookup-symbol . counsel-info-lookup-symbol)
(pop-to-mark-command . counsel-mark-ring)))
(define-key map (vector 'remap (car binding)) (cdr binding)))
map)
"Map for `counsel-mode'.
Remaps built-in functions to counsel replacements.")
btw, instead of helpful-function
it should use helpful-callable
to become a describe-function
replacement.
Aha, OK. So define a global minor mode with a mode map that overrides C-h v
and C-h f
, to save the user from overriding those themselves.
Helpful only has two commands that have built-in equivalents. If we have more, we should definitely do this, but I'm not sure it makes sense yet.
well, it would've saved me from wrongfully using helpful-function
instead of helpful-callable
, and wondering why i didn't see some functions... which turned out to be macros. ;)
there's also C-h o
for -symbol
.
i still think it's a good idea. ;)
something like this:
| =C-h f= | ~helpful-callable~ | ~describe-function~ |
| =C-h v= | ~helpful-variable~ | ~describe-variable~ |
| =C-h k= | ~helpful-key~ | ~describe-key~ |
| =C-h o= | ~helpful-symbol~ | ~describe-symbol~ |
(from general-describe-keybindings
output)