From bfa54c8f5feda477fa383611d10956db46607b8c Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Wed, 19 Feb 2025 17:40:56 -0500 Subject: [PATCH] tweak: change calc keybindings --- config.org | 61 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/config.org b/config.org index f429b0d..64a1e66 100644 --- a/config.org +++ b/config.org @@ -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 " 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.