change osx-command-as default for ⌘ to hyper instead of super
The purpose of this PR is to set the default for ⌘ to `hyper' and to provide the function `kbd-mac-command` to replace `kbd' when defining keybindings for ⌘ in case someone decides to explicitly set osx-command-as to `super' or `alt'. There are problems setting osx-command-as to `alt' and `super', so we use `hyper' as a default instead because, for example: - Using `alt': Command-x or Command-m inserts, respectively: × µ - Using `super': Control-Command-f produces keycode: <C-s-268632078> Setting to `hyper' seems to avoid both types of the above problems. Also, while it is possible, it is not recommended to set to `meta' since standard OSX shortcuts would overshadow important keys such as M-x. Two other small changes include: - Commenting out the code that defines <C-s-268632078> (C-s-f) since it is unnecessary if we use `hyper' as the default; and if we really want to use `super' then we should figure out how to solve the weird keycode issue. - add keybinding for ⌘` (Command-backtick) to `other-window'. Emacs usually swallows this keystroke, so other-window basically restores the default behavior that most Mac OSX users would expect.
This commit is contained in:
parent
5ff0fbe6d9
commit
2215ffe68d
|
@ -15,7 +15,7 @@
|
|||
|
||||
* Description
|
||||
Spacemacs is not just emacs+vim. It can have OSX keybindings too! This layer
|
||||
globally defines common OSX keybindings. ~⌘~ is set to ~super~ and ~⌥~ is set to
|
||||
globally defines common OSX keybindings. ~⌘~ is set to ~hyper~ and ~⌥~ is set to
|
||||
~meta~. Aside from that, there's nothing much, really.
|
||||
|
||||
While in =dired= this layer will try to use =gls= instead of =ls=.
|
||||
|
@ -37,7 +37,7 @@ The different modifier keys can be set as follows:
|
|||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq-defaults dotspacemacs-configuration-layers '(
|
||||
(osx :variables osx-command-as 'super
|
||||
(osx :variables osx-command-as 'hyper
|
||||
osx-option-as 'meta
|
||||
osx-control-as 'control
|
||||
osx-function-as 'none
|
||||
|
@ -115,6 +115,7 @@ To get =gls= install coreutils homebrew:
|
|||
| ~⌘ w~ | Close window |
|
||||
| ~⌘ W~ | Close frame |
|
||||
| ~⌘ n~ | New frame |
|
||||
| ~⌘ `~ | Other frame |
|
||||
| ~⌘ z~ | Undo |
|
||||
| ~⌘ Z~ | Redo |
|
||||
| ~⌃ ⌘ f~ | Toggle fullscreen |
|
||||
|
|
|
@ -16,10 +16,19 @@
|
|||
option key to type common characters.
|
||||
Default: `deprecated'")
|
||||
|
||||
(defvar osx-command-as 'super
|
||||
(defvar osx-command-as 'hyper
|
||||
"Sets the key binding of the `COMMAND' key on OSX.
|
||||
Possible values are `super' `meta' `hyper' `alt' `none'.
|
||||
Default: `super'.")
|
||||
Default: `hyper'.")
|
||||
;; There are problems setting osx-command-as to `alt' and `super',
|
||||
;; so we use `hyper' as a default instead because, for example:
|
||||
;; - Using `alt': Command-x or Command-m inserts, respectively: × µ
|
||||
;; - Using `super': Control-Command-f produces keycode: <C-s-268632078>
|
||||
;; Setting to `hyper' seems to avoid both types of the above problems.
|
||||
;; Also, while it is possible, it is not recommended to set to `meta'
|
||||
;; since standard OSX shortcuts would overshadow important keys such
|
||||
;; as M-x.
|
||||
|
||||
(defvar osx-option-as 'meta
|
||||
"Sets the key binding of the `OPTION' key on OSX.
|
||||
Possible values are `super' `meta' `hyper' `alt' `none'.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
;; this is only applicable to GUI mode
|
||||
(when (display-graphic-p)
|
||||
|
||||
;; `Command' key is by default bound to SUPER (s-*).
|
||||
;; `Command' key is by default bound to HYPER (H-*),
|
||||
;; `Option' key is by default bound to META (M-*).
|
||||
;; `Function' key is by default not rebound.
|
||||
;; `Control' key is by default not rebound.
|
||||
|
@ -48,25 +48,39 @@
|
|||
(when (member key-value allowed-values)
|
||||
(setf (symbol-value internal-var) key-value))))
|
||||
|
||||
(defun kbd-mac-command (keys)
|
||||
"Wraps `kbd' function with Mac OSX compatible Command-key (⌘).
|
||||
KEYS should be a string such as \"f\" which will be turned into values
|
||||
such as \"H-f\", \"s-f\", or \"A-f\" depending on the value of
|
||||
`mac-commmand-modifier' which could be `hyper', `super', or `alt'.
|
||||
KEYS with a string of \"C-f\" are also valid and will be turned into
|
||||
values such as \"H-C-f\".
|
||||
Returns nil if `mac-command-modifier' is set to `none' or something
|
||||
other than the three sane values listed above."
|
||||
(let ((found (assoc mac-command-modifier
|
||||
'((hyper . "H-")
|
||||
(super . "s-")
|
||||
(alt . "A-")))))
|
||||
(when found (kbd (concat (cdr found) keys)))))
|
||||
|
||||
;; Keybindings
|
||||
(global-set-key (kbd "s-=") 'spacemacs/scale-up-font)
|
||||
(global-set-key (kbd "s--") 'spacemacs/scale-down-font)
|
||||
(global-set-key (kbd "s-0") 'spacemacs/reset-font-size)
|
||||
(global-set-key (kbd "s-q") 'save-buffers-kill-terminal)
|
||||
(global-set-key (kbd "s-v") 'yank)
|
||||
(global-set-key (kbd "s-c") 'evil-yank)
|
||||
(global-set-key (kbd "s-a") 'mark-whole-buffer)
|
||||
(global-set-key (kbd "s-x") 'kill-region)
|
||||
(global-set-key (kbd "s-w") 'delete-window)
|
||||
(global-set-key (kbd "s-W") 'delete-frame)
|
||||
(global-set-key (kbd "s-n") 'make-frame)
|
||||
(global-set-key (kbd "s-z") 'undo-tree-undo)
|
||||
(global-set-key (kbd "s-s")
|
||||
(global-set-key (kbd-mac-command "=") 'spacemacs/scale-up-font)
|
||||
(global-set-key (kbd-mac-command "-") 'spacemacs/scale-down-font)
|
||||
(global-set-key (kbd-mac-command "0") 'spacemacs/reset-font-size)
|
||||
(global-set-key (kbd-mac-command "q") 'save-buffers-kill-terminal)
|
||||
(global-set-key (kbd-mac-command "v") 'yank)
|
||||
(global-set-key (kbd-mac-command "c") 'evil-yank)
|
||||
(global-set-key (kbd-mac-command "a") 'mark-whole-buffer)
|
||||
(global-set-key (kbd-mac-command "x") 'kill-region)
|
||||
(global-set-key (kbd-mac-command "w") 'delete-window)
|
||||
(global-set-key (kbd-mac-command "W") 'delete-frame)
|
||||
(global-set-key (kbd-mac-command "n") 'make-frame)
|
||||
(global-set-key (kbd-mac-command "`") 'other-frame)
|
||||
(global-set-key (kbd-mac-command "z") 'undo-tree-undo)
|
||||
(global-set-key (kbd-mac-command "s")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(call-interactively (key-binding "\C-x\C-s"))))
|
||||
(global-set-key (kbd "s-Z") 'undo-tree-redo)
|
||||
(global-set-key (kbd "C-s-f") 'spacemacs/toggle-frame-fullscreen)
|
||||
|
||||
;; window manipulation with command key
|
||||
(global-set-key (kbd "s-1") 'winum-select-window-1)
|
||||
|
@ -79,5 +93,9 @@
|
|||
(global-set-key (kbd "s-8") 'winum-select-window-8)
|
||||
(global-set-key (kbd "s-9") 'winum-select-window-9)
|
||||
|
||||
(global-set-key (kbd-mac-command "Z") 'undo-tree-redo)
|
||||
(global-set-key (kbd-mac-command "C-f") 'spacemacs/toggle-frame-fullscreen)
|
||||
|
||||
;; Emacs sometimes registers C-s-f as this weird keycode
|
||||
(global-set-key (kbd "<C-s-268632070>") 'spacemacs/toggle-frame-fullscreen)))
|
||||
;; (global-set-key (kbd "<C-s-268632070>") 'spacemacs/toggle-frame-fullscreen)
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue