【发布时间】:2014-01-05 19:12:52
【问题描述】:
我想要一个显示变量值的全局键盘快捷键。但是,变量的值可能会根据当前缓冲区中的当前主模式而改变。
我尝试将以下内容添加到我的~/.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)
如果我现在用emacs test.sh 启动Emacs,然后在test.sh 缓冲区中输入M-x describe-variable *current-mode-var*,我会得到
*current-mode-var*'s value is "elisp-mode"
Automatically becomes buffer-local when set.
Documentation:
Not documented as a variable.
虽然我希望得到*current-mode-var*'s value is "sh-mode"
【问题讨论】: