10

How get a list of active minor modes in current buffer?

Docs (info "(elisp)Minor Mode Conventions") say:

 Define a variable whose name ends in ‘-mode’.  We call this the
 "mode variable".  The minor mode command should set this variable.
 The value will be ‘nil’ if the mode is disabled, and non-‘nil’ if
 the mode is enabled.  The variable should be buffer-local if the
 minor mode is buffer-local.

I stop with:

(dolist (m minor-mode-list)
  (when (symbol-value m)
    (push m modes)))

describe-mode sources have notes that:

;; Older packages do not register in minor-mode-list but only in
;; minor-mode-alist.

I don't know if that still valid point...

  • 2
    Doesn't describe-mode give you an adequate list of the active minor modes in the current buffer? – Drew Apr 20 '15 at 1:28
  • 1
    @Drew It sounds like he maybe wants it programmatically? – nanny Apr 20 '15 at 18:56
  • 1
    @nanny: Yes, I guessed that. In that cases, one place to start would be to look at the code for describe-mode - if that is otherwise adequate. – Drew Apr 20 '15 at 20:32
7

If you're just looking to see what minor modes are being used in a buffer, but don't need to use the list programmatically use:

M-x describe-mode

This command will open a new buffer that begins with a full list of your minor modes, as well as giving a brief description of the major modes, and any parent modes that may have been run.

  • 1
    While this may not exactly answer the question of the OP, this was the first result I found when searching for this question. Since Drew's comment solved my use case, I thought it deserved a full answer for future searchers. – Wilduck Jun 1 '16 at 15:08
  • +1 for demonstrating the more general purpose solution to the problem. describe-mode is especially useful! – ephsmith Sep 14 '17 at 2:03
6

Try this:

(mapcar #'car minor-mode-alist)

In fact, you will find that this value often differs from minor-mode-list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.