没有一种简单的方法可以确切地知道单个按键将执行的操作。
如果看到其他行为,请始终检查通用钩子。请参阅此处的列表:http : //www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html
在大多数情况下,重要的是:
- 变更后功能
- 变更前功能
- 首次挂机
- 命令钩后
- 命令前挂机
- 自我插入后钩
您需要检查这些钩子,并查看它们包含的功能,以查看哪个钩子正在修改您的行为。
如果这些挂钩中的功能不能完全描述所观察到的行为,请查看这些功能以获取建议,这些建议将在参考资料中显示describe-function
。
编辑:我已经编写了一些函数来帮助描述一个钩子,而不是一个接一个地更好地描述钩子:https : //gist.github.com/jordonbiondo/bad03e44bb053db0f1eb
可以describe-hook
像其他描述函数一样使用在那里定义。这是它的输出示例:
这是所有代码,以防主意消失:
(defun guess-all-hooks ()
"Return a list of all variables that are probably hook lists."
(let ((syms '()))
(mapatoms
(lambda (sym)
(if (ignore-errors (symbol-value sym))
(let ((name (symbol-name sym)))
(when (string-match "-\\(hook[s]?\\|functions\\)$" name)
(push sym syms))))))
syms))
(defun face-it (str face)
"Apply FACE to STR and return."
(propertize str 'face face))
(defun describe-hook (hook)
"Display documentation about a hook variable and the
functions it contains."
(interactive
(list (completing-read
"Hook: " (mapcar (lambda (x) (cons x nil)) (guess-all-hooks)))))
(let* ((sym (intern hook))
(sym-doc (documentation-property sym 'variable-documentation))
(hook-docs (mapcar
(lambda (func)
(cons func (ignore-errors (documentation func))))
(symbol-value sym))))
(switch-to-buffer
(with-current-buffer (get-buffer-create "*describe-hook*")
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
(insert (face-it "Hook: " 'font-lock-constant-face) "\n\n")
(insert (face-it (concat "`" hook "'") 'font-lock-variable-name-face))
(replace-string "\n" "\n\t" nil
(point)
(save-excursion
(insert "\n" sym-doc "\n\n")
(1- (point))))
(goto-char (point-max))
(insert (face-it "Hook Functions: " 'font-lock-constant-face) "\n\n")
(dolist (hd hook-docs)
(insert (face-it (concat "`" (symbol-name (car hd)) "'")
'font-lock-function-name-face)
": \n\t")
(replace-string "\n" "\n\t" nil
(point)
(save-excursion
(insert (or (cdr hd) "No Documentation") "\n\n")
(1- (point))))
(goto-char (point-max))))
(help-mode)
(help-make-xrefs)
(read-only-mode t)
(setq truncate-lines nil)
(current-buffer)))))
electric-pair-mode
仅在某些主要模式下激活了吗?你仍然可以看到self-insert-command
的"
,当你做C-h k
而electric-pair-mode
被激活?