Last active

meta key switch

  • Download Gist
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
;; Keybonds
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper w)]
(lambda () (interactive) (delete-window)))
(global-set-key [(hyper z)] 'undo)
;; mac switch meta key
(defun mac-switch-meta nil
"switch meta between Option and Command"
(if (eq mac-option-modifier nil)
(setq mac-option-modifier 'meta)
(setq mac-command-modifier 'hyper)
(setq mac-option-modifier nil)
(setq mac-command-modifier 'meta)

Thanks. Very useful.

Is there any possibility to avoid modifying the behavior of the right option key so that I can enter "[]{}" when writing in emacs ?
I tried (setq ns-right-alternate-modifier nil), but it doesn't function

@samspo this mac port doesn't use the ns-* variables and the mac-* variables don't include a right option at the moment. I'm working on a patch for that.

@bartebee Thank you for your answer.

@bartlebee I'd also love to see the ability to have left option work as meta, while right being good old option. I have so many keybindings using super...

+1 for (setq ns-right-alternate-modifier nil)

@samspo In the meantime I hard-wire those keys see

I wanna use command+s to save file or command+q to quit emacs
Then how can I set the command key to its default role?
I set (setq mac-command-modifier nil)
It has no effect

@bartlebee tried this out and found it to be snappy. also like how text is rendered. only thing keeping me from switching full-time is the lack of right-left modifier keys... too many hypers and super keybindings with stubborn muscle memory.

nice work though a+

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.