In describe-mode's definition (in help.el), there's the following piece of code:

;; Older packages do not register in minor-mode-list but only in
;; minor-mode-alist.
(dolist (x minor-mode-alist)
  (setq x (car x))
  (unless (memq x minor-mode-list)
    (push x minor-mode-list)))

How big a concern is this? If I wanted to get a canonical, comprehensive list of minor modes, is it enough to check minor-mode-list, or is doing the above really necessary?

It's fine to be "on the safe side", but describe-mode already makes some powerful assumptions, such as that the control variable for a minor mode has the same name as its toggle command (see define-minor-mode) for more information, so it's a probably not getting "everything" to begin with.

  • If we are to believe that the comment within the source-code is truthful (and there is no reason to suggest that the Emacs team is deceiving us in this particular regard), then "yes", you need to use both just in case older packages are present and active. Your question appears to seek an answer as to whether the comment is truthful, and one of the older Emacs users can probably chime in and see yes or no -- I'll bet my lunch money that it is truthful. :)
    – lawlist
    Feb 8 '16 at 3:32
  • @lawlist Yes, of course whoever wrote comment is not trying to "deceive" us, but there's a lot of old code that may not be applicable anymore. At some point we need to let go of the past and stop inconveniencing ourselves in order to support some package that does not follow conventions established many years ago. Feb 8 '16 at 3:40
  • 1
    As the comment said, I think checking both minor-mode-list and minor-mode-alist is enough to find out all minor mode. I don't understand your "but describe-mode already makes some powerful assumptions...", as far as I see, describe-mode is just testing minor mode variable (in the same name as minor mode toggle function) to know if the minor mode is enabled. Maybe you misunderstood the code?
    – xuchunyang
    Feb 8 '16 at 5:10

Your Answer

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

Browse other questions tagged or ask your own question.