tweak: change calc keybindings

This commit is contained in:
Kiana Sheibani 2025-02-19 17:40:56 -05:00
parent e468119f06
commit bfa54c8f5f
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -2493,15 +2493,46 @@ If prefix ARG is given, delete the window instead of selecting it."
Emacs Calc is the best calculator I've ever used, and given the fact that it's an RPN calculator, that's saying something.
*** Leader Key Bindings
*** Bindings
Typing =C-x *= every time I want to use Calc (very often) is annoying.
**** Evil Bindings
I want to have vim keybindings in Calc, so let's enable the =evil-collection= module for it by removing it from ~+evil-collection-disabled-list~.
#+begin_src emacs-lisp
;; Enable evil-collection-calc
(delq 'calc +evil-collection-disabled-list)
#+end_src
**** Rebindings
Let's also rebind some keys:
- We'll set =[= and =]= to directly begin and end vectors like it did originally, as there is very little reason to use Evil's bindings on these keys.
- =C-r= makes more sense as a redo binding than =D D=.
- The "keep arguments" binding (=K=) was removed by =evil-collection= for some reason? I'm putting it back.
- Selection commands are important, so we'll use =J= for them instead of =z j=.
#+begin_src emacs-lisp
(defadvice! ~/evil-collection-calc-bindings ()
:after #'evil-collection-calc-setup
(map! :map calc-mode-map
:n "C-r" #'calc-redo
:n "[" #'calc-begin-vector
:n "]" #'calc-end-vector
:n "K" #'calc-keep-args
:n "J" (keymap-lookup calc-mode-map "<normal-state> z j"))
(map! :map calc-mode-map
:n "z j" nil))
#+end_src
**** Leader Key Bindings
Typing =C-x *= every time I want to use Calc (very often) is annoying. To alleviate this problem, we can create some keybindings under =SPC C=:
#+begin_src emacs-lisp
(map! :leader
:prefix ("#" . "calc")
:desc "Emacs Calc"
"#" #'calc
:prefix ("C" . "calc")
:desc "Emacs Calc"
"c" #'calc
:desc "Emacs Calc (full window)"
@ -2553,26 +2584,6 @@ what type of visual state is currently active."
(calc-grab-region top bot arg)))
#+end_src
*** Evil Bindings
I want to have vim keybindings in Calc, so let's enable the =evil-collection= module for it by removing it from ~+evil-collection-disabled-list~.
#+begin_src emacs-lisp
;; Enable evil-collection-calc
(delq 'calc +evil-collection-disabled-list)
#+end_src
Let's also rebind some keys. We'll set =[= and =]= to directly begin and end vectors like it did originally, and =C-r= makes more sense as a redo binding than =D D=.
#+begin_src emacs-lisp
(defadvice! ~/evil-collection-calc-bindings ()
:after #'evil-collection-calc-setup
(map! :map calc-mode-map
:n "C-r" #'calc-redo
:n "[" #'calc-begin-vector
:n "]" #'calc-end-vector))
#+end_src
*** Appearance
Calc doesn't use faces to show selections by default, which I think is rather strange.