简体   繁体   中英

Super key binding in emacs

(global-set-key (kbd "<s-d>") 'duplicate-line)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECB MODE;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "<s-left>") 'ecb-goto-window-methods)
(global-set-key (kbd "<s-right>") 'ecb-goto-window-edit1)
(global-set-key (kbd "<s-down>") 'ecb-goto-window-history)
(global-set-key (kbd "<s-up>") 'ecb-goto-window-sources)
(global-set-key (kbd "<s-home>") 'ecb-goto-window-directories)

This is part of my .emacs file. I am facing a strange problem while binding a key combination containing super key. Whenever I bind a function to super-key + <alphanumberic value> it refuses to work.
In the above file all the bindings except <sd> are working fine.
I am using emacs 24.3 on fedora 13

The reason the kbd macro is so convenient is that the argument you pass it is exactly the same thing that Emacs tells you when you ask about a key binding. You're guessing at the argument, but you never need to do that.

When you type Ch k (or Ch c ) and then the key sequence in question, Emacs will display a message describing that binding. In this instance it will describe super-key + d as sd .

Therefore you can use (kbd "sd") to refer to it.

  • Ask Emacs to describe a key sequence
  • Plug the answer into kbd

Some selection which works here:

(global-set-key [(super ?\ö)] 'ar-beginning-of-comment-atpt)

(global-set-key [(super ?\Ö)] 'ar-end-of-comment-atpt)

(global-set-key [(super p)] 'View-sroll-line-backward)

(global-set-key [(super s)] 'hs-hide-all)

(global-set-key [(super tab)] 'scroll-up)

(global-set-key [(super \{)] 'ar-brace-region-atpt)

(global-set-key [(super space)] 'ar-whitespace-to-minus)

(global-set-key [(super kp-4)] 'missing-py-variable-name-face-lp-1215791-test)

All of these are from . . . /lisp/term/ns-win.el . . . /lisp/term/ns-win.el

(define-key global-map [?\s-,] 'customize)
(define-key global-map [?\s-'] 'next-multiframe-window)
(define-key global-map [?\s-`] 'other-frame)
(define-key global-map [?\s-~] 'ns-prev-frame)
(define-key global-map [?\s--] 'center-line)
(define-key global-map [?\s-:] 'ispell)
(define-key global-map [?\s-?] 'info)
(define-key global-map [?\s-^] 'kill-some-buffers)
(define-key global-map [?\s-&] 'kill-this-buffer)
(define-key global-map [?\s-C] 'ns-popup-color-panel)
(define-key global-map [?\s-D] 'dired)
(define-key global-map [?\s-E] 'edit-abbrevs)
(define-key global-map [?\s-L] 'shell-command)
(define-key global-map [?\s-M] 'manual-entry)
(define-key global-map [?\s-S] 'ns-write-file-using-panel)
(define-key global-map [?\s-a] 'mark-whole-buffer)
(define-key global-map [?\s-c] 'ns-copy-including-secondary)
(define-key global-map [?\s-d] 'isearch-repeat-backward)
(define-key global-map [?\s-e] 'isearch-yank-kill)
(define-key global-map [?\s-f] 'isearch-forward)
(define-key global-map [?\s-g] 'isearch-repeat-forward)
(define-key global-map [?\s-h] 'ns-do-hide-emacs)
(define-key global-map [?\s-H] 'ns-do-hide-others)
(define-key global-map [?\s-j] 'exchange-point-and-mark)
(define-key global-map [?\s-k] 'kill-this-buffer)
(define-key global-map [?\s-l] 'goto-line)
(define-key global-map [?\s-m] 'iconify-frame)
(define-key global-map [?\s-n] 'make-frame)
(define-key global-map [?\s-o] 'ns-open-file-using-panel)
(define-key global-map [?\s-p] 'ns-print-buffer)
(define-key global-map [?\s-q] 'save-buffers-kill-emacs)
(define-key global-map [?\s-s] 'save-buffer)
(define-key global-map [?\s-t] 'ns-popup-font-panel)
(define-key global-map [?\s-u] 'revert-buffer)
(define-key global-map [?\s-v] 'yank)
(define-key global-map [?\s-w] 'delete-frame)
(define-key global-map [?\s-x] 'kill-region)
(define-key global-map [?\s-y] 'ns-paste-secondary)
(define-key global-map [?\s-z] 'undo)
(define-key global-map [?\s-|] 'shell-command-on-region)
(define-key global-map [s-kp-bar] 'shell-command-on-region)
;; (as in Terminal.app)
(define-key global-map [s-right] 'ns-next-frame)
(define-key global-map [s-left] 'ns-prev-frame)

Here is an example for ctrl+opt+command+s on a US Apple wired mini-keyboard:

(define-key global-map (kbd "<M-C-s-268632083>") 'help-for-help)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM