我有興趣創建一個基於用戶定義標準運行的交互式準後命令鉤,如: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