2
votes

I recently switched to typing on Dvorak layout. But after some time, I decided to use Dvorak only in Emacs - so all other key bindings on my system would not be screwed.

So, I took the following from some question on StackOverflow.com:

(defadvice switch-to-buffer (after activate-input-method activate)
  (activate-input-method "english-dvorak"))

It switches the input method in all new buffers to dvorak. It works fine, but the there is the problem - the scratch buffer keeps it's default english layout, and all file choosing "dialogs" (C-x C-f) also keep it - which is kinda annoying, because it requires me to switch "typing mindsets" several times a minute.

Is there a way to enable the dvorak layout globally in emacs - and still keep the default shortcuts (like that C-x on default english)?

EDIT:

The answer to my problems:

(defadvice switch-to-buffer (after activate-input-method activate)
  (activate-input-method "english-dvorak")) 
(add-hook 'minibuffer-setup-hook (lambda () (set-input-method "english-dvorak")))
2

2 Answers

3
votes

You might try something like (guaranteed 100% untested code):

(define-minor-mode dvorak-minor-mode "Use Dvorak IM." :lighter nil
  (if dvorak-minor-mode (activate-input-method "english-dvorak")))
(define-global-minor-mode dvorak-mode dvorak-minor-mode dvorak-minor-mode)
0
votes

I use Emacs version 28 with emacsclient. I had to tweak @Stefan's answer a bit to get Emacs server to successfully start up - here's the full code I use to get dvorak enabled in all my buffers:

(define-minor-mode dvorak-minor-mode "Use english-dvorak input method." :lighter nil
  (if (and dvorak-minor-mode (not (minibufferp)))
    (activate-input-method "english-dvorak")))
(define-global-minor-mode global-dvorak-mode dvorak-minor-mode dvorak-minor-mode)
(global-dvorak-mode t)
(add-hook 'minibuffer-setup-hook (lambda () (set-input-method "english-dvorak")))