一般来说,定义minor-mode时,默认的变量和mode是同一个名字,但是有的minor-mode不同,比如:
(define-minor-mode read-only-mode
:variable buffer-read-only
;; We're saving this value here so that we can restore the
;; readedness state after reverting the buffer to the value that's
;; been explicitly set by the user.
(setq-local read-only-mode--state buffer-read-only)
(cond
((and (not buffer-read-only) view-mode)
(View-exit-and-edit)
(setq-local view-read-only t)) ; Must leave view mode.
((and buffer-read-only view-read-only
;; If view-mode is already active, `view-mode-enter' is a nop.
(not view-mode)
(not (eq (get major-mode 'mode-class) 'special)))
(view-mode-enter))))
read-only-mode 所定义的是 :variable buffer-read-only
, 如何获取 任何一个minor mode相关绑定的这个变量呢?我好像没找到方法,不会真要到定义文件正则匹配吧?虽然本质上我想要确定某个minor mode 是否已经enable,有更好的方法吗?