【发布时间】:2021-02-20 20:53:02
【问题描述】:
我想写一个 Elisp 脚本
- 打开
auto-save-visited-mode(如果它已关闭),然后 - 如果它已经打开,什么也不做。
如何查看 Elisp 中当前是否启用了此模式?
更新 1:M-x describe-mode 显示所有启用的次要模式的列表。
更新 2: 根据this answer,您可以使用此代码显示所有活动次要模式的列表:
(defun which-active-modes ()
"Give a message of which minor modes are enabled in the current buffer."
(interactive)
(let ((active-modes))
(mapc (lambda (mode) (condition-case nil
(if (and (symbolp mode) (symbol-value mode))
(add-to-list 'active-modes mode))
(error nil) ))
minor-mode-list)
(message "Active modes are %s" active-modes)))
(which-active-modes)
更新 3: 似乎可以使用的最终版本:
(if auto-save-visited-mode
(message "The mode is on")
(message "The mode is off")
)
【问题讨论】: