我试图创建一个 global minor mode,mode的map总是不对,当我 enable multi-screens-mode
的时候,定义的那些命令的快捷键变成了 [
和 ]
。快捷键应该是 C-M-] ]
这样的。不知道是我哪里写得不对么?代码如下:
(defgroup multi-screens nil
"Multi-screens minor mode customization options."
:prefix "multi-screens-"
:group 'multi-screens)
(defcustom multi-screens-keybinding-prefix (kbd "C-M-]")
"Specify multi-screens-mode keybindings prefix before loading."
:type 'kbd
:group 'multi-screens)
(defun multi-screens-scroll-other-frame ()
"Scroll other frame.
This is helpful for multiple monitor screens."
(interactive)
(other-frame +1)
(call-interactively 'scroll-up-command)
(other-frame -1))
(defun multi-screens-scroll-other-frame-down ()
"Scroll other frame down.
This is helpful for multiple monitor screens."
(interactive)
(other-frame +1)
(call-interactively 'scroll-down-command)
(other-frame -1))
(defvar multi-screens-mode-map
(let ((map (make-sparse-keymap)))
(unless (keymapp map)
(global-set-key multi-screens-keybinding-prefix map)
(define-key map (kbd "]") 'multi-screens-scroll-other-frame)
(define-key map (kbd "[") 'multi-screens-scroll-other-frame-down))
map)
"Multi-screens-mode map.")
;;;###autoload
(define-minor-mode multi-screens-mode
"Multi-screens global minor mode to controlling frames for multiple screens."
:require "multi-screens"
:global t
:group 'multi-screens
:keymap multi-screens-mode-map
(if multi-screens-mode
(message "multi-screens-mode enabled.")
(message "multi-screens-mode disabled.")))