我有兴趣创建一个基于用户定义标准运行的交互式准后命令钩,如:Emacs - 创建一个交互式的只准后命令钩
向上(交互式);
Down(interactive);
Left(interactive);
Right(interactive);
将文本插入缓冲区的任何(交互式)键 - 例如aA-zZ; 0-9;空间; (上/下)(交互式)。
鼠标滚轮(上/下)(交互式)。
相信后命令钩包括更多,我想要当钩被激活以限制/控制。
任何有关如何创建这样一个钩子的指导,将不胜感激。
2013年5月3日:例如草案基于由下面@phils答案。
(add-hook 'post-command-hook 'quasi-post-command-hook)
(defvar quasi-this-command-functions '(next-line previous-line left-char right-char
self-insert-command newline delete-backward-char delete-forward-char
indent-for-tab-command mwheel-scroll lawlist-mwheel-scroll end-of-visual-line
beginning-of-visual-line end-of-buffer beginning-of-buffer lawlist-forward-entity
lawlist-backward-entity left-word right-word forward-word backward-word)
"Variable list of functions that trigger the `quasi-post-command-hook`.")
(defvar quasi-major-mode-inclusions '(text-mode emacs-lisp-mode)
"Variable list of major modes where the `quasi-post-command-hook` operates.")
(defun quasi-post-command-hook()
(unless (minibufferp)
(when
(and
(memq major-mode quasi-major-mode-inclusions)
(memq this-command quasi-this-command-functions))
(message "this-command: %s" this-command))))
真棒!非常感谢你 - 非常感谢! :) – lawlist