我想要一个显示变量值的全局键盘快捷键。但是,该变量的值可能会根据当前缓冲区中的当前主要模式而变化。
我尝试将以下内容添加到我的~/.emacs:
(defun my-elisp-mode-setup ()
(defvar-local *current-mode-var* "elisp-mode")
)
(defun my-sh-mode-setup ()
(defvar-local *current-mode-var* "sh-mode")
)
(add-hook 'emacs-lisp-mode-hook 'my-elisp-mode-setup)
(add-hook 'sh-mode-hook 'my-sh-mode-setup)
Run Code Online (Sandbox Code Playgroud)
如果我现在启动 Emacs emacs test.sh,然后在缓冲区M-x describe-variable *current-mode-var*中输入test.sh,我会得到
*current-mode-var*'s value is "elisp-mode"
Automatically becomes buffer-local when set.
Documentation:
Not documented as a variable.
Run Code Online (Sandbox Code Playgroud)
虽然我期望得到*current-mode-var*'s value is "sh-mode"
| 归档时间: |
|
| 查看次数: |
2720 次 |
| 最近记录: |