help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I find out what minor modes are in effect?


From: Pascal J. Bourguignon
Subject: Re: How do I find out what minor modes are in effect?
Date: Wed, 11 Apr 2012 17:54:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Doug Lewan <dougl@shubertticketing.com> writes:

> I'm writing a function that needs to change the major mode to do its stuff 
> properly.
> That can turn off minor modes too.
> The obvious polite thing to do is turn them all back on when I'm done.
>
> Resetting the major mode is easy:
> (defun vertical-text (text)
>   (let ((mode-to-restore major-mode)
>     (picture-mode)
>     ...
>     (funcall mode-to-restore)))
>
> How do I find out what minor modes are in effect?

(defun current-minor-modes (&optional buffer)
  "The list of the minor modes currently active in the buffer (or current 
buffer)."
  (let ((result '()))
    (with-current-buffer (or buffer (current-buffer))
      (dolist (mode minor-mode-list result)
        (when (and (boundp mode) (symbol-value mode))
          (push mode result))))))

> And in what order they were invoked?

Depending on where they're called, in the various hooks and init files.


> (They can stomp on each other and 

Indeed.


Have a look at with-mode-local too.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]