xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
484 stars 82 forks source link

how to make calc mode default to input-mode #104

Open spiderbit opened 4 years ago

spiderbit commented 4 years ago

If I start calc mode and want to compute 5 numbers and most of the time I don't want to paste something so switching manually to insert mode after each number is super annoying.

So I thought let's setup some hook to bring it after each number in input mode again. Sadly calc starts when you type a number a minibuffer input field so it's not in the same buffer anymore, and with the buffer switch it activates command mode each time.

So I tried minibuffer-exit-hook:

  (add-hook 'minibuffer-exit-hook
        (when (equal "Calculator" mode-name)
          (xah-fly-insert-mode-activate)))

Which does not work, any idea?

spiderbit commented 4 years ago

So I just looked a bit into that problem didn't even remember that I reported this as "bug" already, but the solution to this is the following, I wonder if it makes sense to add that into xah-fly-keys upstream because I think I see no advantage to have command mode active by default in calc mode:

  (add-hook 'calc-start-hook #'xah-fly-insert-mode-activate)
  (advice-add 'calcDigit-start :after #'xah-fly-insert-mode-activate)

I don't know if I need to open a seperate bug but similar solution for org-agenda buffer:

  (add-hook 'org-agenda-mode-hook #'xah-fly-insert-mode-activate)
  (advice-add 'org-agenda-redo :after #'xah-fly-insert-mode-activate)
spiderbit commented 4 years ago

small mistake it's not the org-agenda-mode-hook but org-agenda-finalize-hook:

(add-hook 'org-agenda-finalize-hook #'xah-fly-insert-mode-activate)