原生 emacs 怎么绑定 Space键作为组合键

(global-set-key (kbd "SPC f r") 'counsel-recentf)

Debugger entered--Lisp error: (error "Key sequence SPC f r starts with non-prefix key SP...")
  define-key((keymap #^[nil nil keymap 
#^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit delete-backward-char indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward swiper transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] #^^[1 0 #^^[2 0 
#^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit delete-backward-char indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward swiper transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] (S-mouse-3 . kmacro-end-call-mouse) (paste . clipboard-yank) (copy . clipboard-kill-ring-save) (cut . clipboard-kill-region) (f18 . clipboard-yank) (f16 . clipboard-kill-ring-save) (f20 . clipboard-kill-region) (C-wheel-down . mouse-wheel-text-scale) (C-wheel-up . mouse-wheel-text-scale) (M-wheel-left . mwheel-scroll) (M-wheel-right . mwheel-scroll) (M-wheel-down . mwheel-scroll) (M-wheel-up . mwheel-scroll) (S-wheel-left . mwheel-scroll) (S-wheel-right . mwheel-scroll) (S-wheel-down . mwheel-scroll) (S-wheel-up . mwheel-scroll) (wheel-left . mwheel-scroll) (wheel-right . mwheel-scroll) (wheel-down . mwheel-scroll) (wheel-up . mwheel-scroll) (rwindow . ignore) (lwindow . ignore) (M-noname . ignore) (C-noname . ignore) (noname . ignore) (language-change . ignore) (C-drag-n-drop . w32-drag-n-drop-other-frame) (drag-n-drop . w32-drag-n-drop) (tool-bar menu-item "tool bar" ignore :filter tool-bar-make-keymap) (tab-bar menu-item "tab bar" ignore :filter tab-bar-make-keymap) (C-f10 . buffer-menu-open) (f10 . menu-bar-open) (bottom-left-corner keymap (mouse-1 . ignore) (down-mouse-1 . mouse-drag-bottom-left-corner)) (bottom-edge keymap (mouse-1 . ignore) (down-mouse-1 . mouse-drag-bottom-edge)) (bottom-right-corner keymap (mouse-1 . ignore) (down-mouse-1 . mouse-drag-bottom-right-corner)) ...) " fr" counsel-recentf)
  global-set-key(" fr" counsel-recentf)
  eval((global-set-key (kbd "SPC f r") 'counsel-recentf) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

原生 emacs 怎么绑定 Space键作为组合键

global下大概是不支持的,很显然不以组合键为开头是不行的……evil和meow这些是用mode实现的,你也可以写一个自己的mode,重新实现一下self-insert-command,然后用define-key绑快捷键。

或者如果你用mac,你可以试着用karabiner从系统层面改掉你的空格键,因为它可以设置复杂的rules,具备可行性。

……但为什么要这么做呢?直接evil或meow不好嘛 :rofl:

(global-set-key (kbd "SPC") '())
(global-set-key (kbd "SPC f r") 'counsel-recentf)

上面这样写先把spc原生绑定的函数取消后在绑定就可以,这样写绑定的按键多了就有点麻烦,可以用 define-prefix-command,也是原生的。但感觉还是没有hydra好

另外我又想问了,空格作为组合键怎么实现长按

1 个赞