I want to write an Elisp script that will
- turn the
auto-save-visited-mode
on, if it is off, and - do nothing if it is already turned on.
How can I find out whether or not this mode is enabled at the moment in Elisp?
Update 1: M-x describe-mode
shows a list of all enabled minor modes.
Update 2: According to this answer you can display a list of all active minor modes using this code:
(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)
Update 3: Final version that seems to work:
(if auto-save-visited-mode
(message "The mode is on")
(message "The mode is off")
)