3

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?

6
  • emacs.stackexchange.com/tags/elisp/info Commented May 29, 2020 at 23:02
  • 2
    @Drew, I think that only applies to the [elisp] tag at S.E.? Here at S.O., I believe it's valid to use it for "programming in elisp" questions. Commented May 29, 2020 at 23:28
  • @phils: I think it applies to SO as well. it should, at least (IMO). More specific programming-related tags should be used (and created if necessary). Commented May 30, 2020 at 4:43
  • 1
    Are any other programming language tags used that way at S.O.? AFAIK the tags for programming languages are widely used for tagging questions about programming using that language. At E.S. the context is already Emacs and so "programming with elisp" will invariably be implicit, so the [elisp] definition is reasonable over there. We might say that the inclusion of an [emacs] tag at S.O. provides the same context as E.S., but I nevertheless don't see why [elisp] would be used differently at S.O. to any other language tag. Commented May 30, 2020 at 5:14
  • 1
    At minimum, there's a large history of questions which are not tagged that way, so the consistency is not there. I think this would need Meta discussion and general agreement. Commented May 30, 2020 at 5:16

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.