Reputation: 2422
Another Elisp package defines a minor mode as global. In other words, the package defines the minor mode with:
(define-minor-mode some-minor-mode
;; ... other stuff ...
:global t)
I'd like to make it buffer-local so that when I activate it, it only applies to the buffer in which it is activated. How do I do this?
Upvotes: 2
Views: 384
Reputation: 73246
You can't. Or at least, you can't in a generic way.
When a minor mode is defined as global, the logic of the mode will undoubtedly make that exact same assumption, and there's no generic change you could make which would cause any arbitrary global minor mode to have only buffer-local effects.
Furthermore, for some global modes a buffer-local variant wouldn't even make sense, such as modes which affect window configurations or frame parameters.
Global modes have to be treated on a case-by-case basis, looking at their specific implementation details. Depending on the code in question, you might be able to achieve your goal for some particular mode; but that same approach would not be guaranteed to work for all global modes.
It's worth mentioning that there are "globalized" minor modes which blend the other two concepts, by taking an existing buffer-local minor mode, and then defining a global mode which enables or disables the buffer-local mode en masse in all of the applicable buffers. You can't go in the other direction, though -- if you don't already have a buffer-local mode, then you would have to write that first.
Upvotes: 2