meow 插入模式下部分原生按键失效

目前正在使用 meow,但是在 insert-mode 下,部分原生按键,比如M-x,M-b,M-f,C-M->等快捷键提示 “xxx is undefined”;其它例如 C-a, C-e 等快捷键却是正常的,想请问一下这是默认行为吗?

(ps:normal mode 下的快捷键以及自定义的快捷键都是正常工作的, 没有什么问题)

我的 meow 相关配置如下所示:

(defun meow-setup ()
  (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  (meow-motion-overwrite-define-key
   '("j" . meow-next)
   '("k" . meow-prev)
   '("<escape>" . ignore))
  (meow-leader-define-key
   ;; SPC j/k will run the original command in MOTION state.
   '("j" . "H-j")
   '("k" . "H-k")
   ;; Use SPC (0-9) for digit arguments.
   '("1" . meow-digit-argument)
   '("2" . meow-digit-argument)
   '("3" . meow-digit-argument)
   '("4" . meow-digit-argument)
   '("5" . meow-digit-argument)
   '("6" . meow-digit-argument)
   '("7" . meow-digit-argument)
   '("8" . meow-digit-argument)
   '("9" . meow-digit-argument)
   '("0" . meow-digit-argument)
   '("/" . meow-keypad-describe-key)
   '("?" . meow-cheatsheet))
  (meow-normal-define-key
   '("0" . meow-expand-0)
   '("9" . meow-expand-9)
   '("8" . meow-expand-8)
   '("7" . meow-expand-7)
   '("6" . meow-expand-6)
   '("5" . meow-expand-5)
   '("4" . meow-expand-4)
   '("3" . meow-expand-3)
   '("2" . meow-expand-2)
   '("1" . meow-expand-1)
   '("-" . negative-argument)
   '(";" . meow-reverse)
   '("," . meow-inner-of-thing)
   '("." . meow-bounds-of-thing)
   '("[" . meow-beginning-of-thing)
   '("]" . meow-end-of-thing)
   '("a" . meow-append)
   '("A" . meow-open-below)
   '("b" . meow-back-word)
   '("B" . meow-back-symbol)
   '("c" . meow-change)
   '("d" . meow-delete)
   '("D" . meow-backward-delete)
   '("e" . meow-next-word)
   '("E" . meow-next-symbol)
   '("f" . meow-find)
   '("g" . meow-cancel-selection)
   '("G" . meow-grab)
   '("h" . meow-left)
   '("H" . meow-left-expand)
   '("i" . meow-insert)
   '("I" . meow-open-above)
   '("j" . meow-next)
   '("J" . meow-next-expand)
   '("k" . meow-prev)
   '("K" . meow-prev-expand)
   '("l" . meow-right)
   '("L" . meow-right-expand)
   '("m" . meow-join)
   '("n" . meow-search)
   '("o" . meow-block)
   '("O" . meow-to-block)
   '("p" . meow-yank)
   '("q" . meow-quit)
   '("Q" . meow-goto-line)
   '("r" . meow-replace)
   '("R" . meow-swap-grab)
   '("s" . meow-kill)
   '("t" . meow-till)
   '("u" . meow-undo)
   '("U" . meow-undo-in-selection)
   '("v" . meow-visit)
   '("w" . meow-mark-word)
   '("W" . meow-mark-symbol)
   '("x" . meow-line)
   '("X" . meow-goto-line)
   '("y" . meow-save)
   '("Y" . meow-sync-grab)
   '("z" . meow-pop-selection)
   '("'" . repeat)
   ;; '("<escape>" . ignore)
   ;; notice that do not set a keybinding for ESC, e.g '("ESC" . meow-last-buffer), other wise some keybinding will be lost
   '("<escape>" . meow-last-buffer)))



(use-package meow
  :ensure t
  :config
  (meow-setup)
  (define-key meow-insert-state-keymap (kbd "ESC") #'meow-insert-exit)

  (meow-global-mode 1)    
  (setq meow-expand-hint-remove-delay 3))

不是 meow 的默认行为

1 个赞

emacs -Q 能复现吗?

1 个赞

可以。

normal-mode 下是没有问题的,但 insert-mode 下就有部分用不了,包括 M-x。

(define-key meow-insert-state-keymap (kbd "ESC") #'meow-insert-exit)

这行代码换成

(define-key meow-insert-state-keymap (kbd "<escape>") #'meow-insert-exit)
1 个赞

好像还是不大行

你按下 Ctrl + h l 执行下view-lossage,看下你之前执行了啥命令

纯好奇,你试试把这段代码加进去

(add-hook 'meow-insert-mode-hook
          (lambda ()
              (local-set-key (kbd "M-b") 'backward-word)))

我想知道能不能暂时解决你的问题。

居然还是不行。。。

复现步骤:

  1. git clone https://github.com/meow-edit/meow.git ~/.emacs.d/meow
  2. emacs -Q, 粘贴代码:

(add-to-list 'load-path "~/.emacs.d/meow")
(require 'meow)

(defun meow-setup ()
  (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  (meow-motion-overwrite-define-key
   '("j" . meow-next)
   '("k" . meow-prev)
   '("<escape>" . ignore))
  (meow-leader-define-key
   ;; SPC j/k will run the original command in MOTION state.
   '("j" . "H-j")
   '("k" . "H-k")
   ;; Use SPC (0-9) for digit arguments.
   '("1" . meow-digit-argument)
   '("2" . meow-digit-argument)
   '("3" . meow-digit-argument)
   '("4" . meow-digit-argument)
   '("5" . meow-digit-argument)
   '("6" . meow-digit-argument)
   '("7" . meow-digit-argument)
   '("8" . meow-digit-argument)
   '("9" . meow-digit-argument)
   '("0" . meow-digit-argument)
   '("/" . meow-keypad-describe-key)
   '("?" . meow-cheatsheet))
  (meow-normal-define-key
   '("0" . meow-expand-0)
   '("9" . meow-expand-9)
   '("8" . meow-expand-8)
   '("7" . meow-expand-7)
   '("6" . meow-expand-6)
   '("5" . meow-expand-5)
   '("4" . meow-expand-4)
   '("3" . meow-expand-3)
   '("2" . meow-expand-2)
   '("1" . meow-expand-1)
   '("-" . negative-argument)
   '(";" . meow-reverse)
   '("," . meow-inner-of-thing)
   '("." . meow-bounds-of-thing)
   '("[" . meow-beginning-of-thing)
   '("]" . meow-end-of-thing)
   '("a" . meow-append)
   '("A" . meow-open-below)
   '("b" . meow-back-word)
   '("B" . meow-back-symbol)
   '("c" . meow-change)
   '("d" . meow-delete)
   '("D" . meow-backward-delete)
   '("e" . meow-next-word)
   '("E" . meow-next-symbol)
   '("f" . meow-find)
   '("g" . meow-cancel-selection)
   '("G" . meow-grab)
   '("h" . meow-left)
   '("H" . meow-left-expand)
   '("i" . meow-insert)
   '("I" . meow-open-above)
   '("j" . meow-next)
   '("J" . meow-next-expand)
   '("k" . meow-prev)
   '("K" . meow-prev-expand)
   '("l" . meow-right)
   '("L" . meow-right-expand)
   '("m" . meow-join)
   '("n" . meow-search)
   '("o" . meow-block)
   '("O" . meow-to-block)
   '("p" . meow-yank)
   '("q" . meow-quit)
   '("Q" . meow-goto-line)
   '("r" . meow-replace)
   '("R" . meow-swap-grab)
   '("s" . meow-kill)
   '("t" . meow-till)
   '("u" . meow-undo)
   '("U" . meow-undo-in-selection)
   '("v" . meow-visit)
   '("w" . meow-mark-word)
   '("W" . meow-mark-symbol)
   '("x" . meow-line)
   '("X" . meow-goto-line)
   '("y" . meow-save)
   '("Y" . meow-sync-grab)
   '("z" . meow-pop-selection)
   '("'" . repeat)
   ;; '("<escape>" . ignore)
   ;; notice that do not set a keybinding for ESC, e.g '("ESC" . meow-last-buffer), otherwise some keybinding will be lost
   '("<escape>" . meow-last-buffer)))


(use-package meow
  :ensure t
  :config
  (meow-setup)
  ;; (define-key meow-insert-state-keymap (kbd "ESC") #'meow-insert-exit)
  (define-key meow-insert-state-keymap (kbd "<escape>") #'meow-insert-exit)
  (meow-global-mode 1)
  ;;          insert mode 
  ;;(add-hook 'focus-out-hook 'meow-insert-exit)
  ;;         
  ;; (setq meow-expand-hint-remove-delay 3)
  )
  (add-hook 'meow-insert-mode-hook
          (lambda ()
              (local-set-key (kbd "M-b") 'backward-word)))
  1. insert-mode 下执行 M-x, M-f, M-b 等

新开的 emacs -Q 吗

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with ‘C-x C-f’ and enter text in its buffer.

(defun meow-setup ()
  (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  (meow-motion-overwrite-define-key
   '("j" . meow-next)
   '("k" . meow-prev)
   '("<escape>" . ignore))
  (meow-leader-define-key
   ;; SPC j/k will run the original command in MOTION state.
   '("j" . "H-j")
   '("k" . "H-k")
   ;; Use SPC (0-9) for digit arguments.
   '("1" . meow-digit-argument)
   '("2" . meow-digit-argument)
   '("3" . meow-digit-argument)
   '("4" . meow-digit-argument)
   '("5" . meow-digit-argument)
   '("6" . meow-digit-argument)
   '("7" . meow-digit-argument)
   '("8" . meow-digit-argument)
   '("9" . meow-digit-argument)
   '("0" . meow-digit-argument)
   '("/" . meow-keypad-describe-key)
   '("?" . meow-cheatsheet))
  (meow-normal-define-key
   '("0" . meow-expand-0)
   '("9" . meow-expand-9)
   '("8" . meow-expand-8)
   '("7" . meow-expand-7)
   '("6" . meow-expand-6)
   '("5" . meow-expand-5)
   '("4" . meow-expand-4)
   '("3" . meow-expand-3)
   '("2" . meow-expand-2)
   '("1" . meow-expand-1)
   '("-" . negative-argument)
   '(";" . meow-reverse)
   '("," . meow-inner-of-thing)
   '("." . meow-bounds-of-thing)
   '("[" . meow-beginning-of-thing)
   '("]" . meow-end-of-thing)
   '("a" . meow-append)
   '("A" . meow-open-below)
   '("b" . meow-back-word)
   '("B" . meow-back-symbol)
   '("c" . meow-change)
   '("d" . meow-delete)
   '("D" . meow-backward-delete)
   '("e" . meow-next-word)
   '("E" . meow-next-symbol)
   '("f" . meow-find)
   '("g" . meow-cancel-selection)
   '("G" . meow-grab)
   '("h" . meow-left)
   '("H" . meow-left-expand)
   '("i" . meow-insert)
   '("I" . meow-open-above)
   '("j" . meow-next)
   '("J" . meow-next-expand)
   '("k" . meow-prev)
   '("K" . meow-prev-expand)
   '("l" . meow-right)
   '("L" . meow-right-expand)
   '("m" . meow-join)
   '("n" . meow-search)
   '("o" . meow-block)
   '("O" . meow-to-block)
   '("p" . meow-yank)
   '("q" . meow-quit)
   '("Q" . meow-goto-line)
   '("r" . meow-replace)
   '("R" . meow-swap-grab)
   '("s" . meow-kill)
   '("t" . meow-till)
   '("u" . meow-undo)
   '("U" . meow-undo-in-selection)
   '("v" . meow-visit)
   '("w" . meow-mark-word)
   '("W" . meow-mark-symbol)
   '("x" . meow-line)
   '("X" . meow-goto-line)
   '("y" . meow-save)
   '("Y" . meow-sync-grab)
   '("z" . meow-pop-selection)
   '("'" . repeat)
   ;; '("<escape>" . ignore)
   ;; notice that do not set a keybinding for ESC, e.g '("ESC" . meow-last-buffer), otherwise some keybinding will be lost
   '("<escape>" . meow-last-buffer)))

(add-to-list 'load-path (file-truename "~/.emacs.d/meow"))
(require 'meow)
(meow-setup)
(define-key meow-insert-state-keymap (kbd "<escape>") #'meow-insert-exit)
(meow-global-mode 1)

我自己这样执行是没问题的

耶?好奇怪啊,我新开一个 emacs -Q 窗口,执行 require meow 的两份代码也都没有出错。 但一旦执行了我开帖时的代码之后,就算再执行这两份代码也会出错了。

好像是这个问题,修改了之后重启我的配置也不会出错了。但是相应的,我没法用 C-[ 进入 normal-mode 了。 C-[ 按得还挺顺手的,有没有不冲突的办法呢?

我都没有给meow-insert-exit绑定按键,你直接不要这行代码试试。

之前就是没法用 C-[ 进入 normal mode, 才给 ESC 绑定的代码,结果反而出问题了 :joy: 刚才试了一下,去掉了之后果然 C-[ 会弹出 which-key 的菜单。。。 我记得好像是 C-[ 会被 emacs 翻译成 M- 修饰键,不知道大佬晓不晓得怎么把 C-[ 搞成和 Esc 键一样的行为呢?

看issue呗,貌似有人问过这个问题。

2 个赞

非常好答案,使我meow纵享丝滑。

话说我之前找了好几次都没找到,属实是有点眼神不好。。。

(use-package meow
  :ensure t
  :config
  (meow-setup)
  (when window-system
    (define-key input-decode-map (kbd "C-[") [control-bracketleft])
    (define-key meow-insert-state-keymap [control-bracketleft] 'meow-insert-exit))
  
  (meow-global-mode 1)
  (setq meow-expand-hint-remove-delay 3))

顺代贴一下配置,以及改键建议:Caps Lock → Ctrl