all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* conditionally enabling a mode in define-minor-mode context
@ 2014-05-11  8:50 Matthias Dahl
  2014-05-11 19:30 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Dahl @ 2014-05-11  8:50 UTC (permalink / raw
  To: help-gnu-emacs

Hello @all...

I'm currently working on a new minor mode which requires that for every
newly opened buffer/file which matches several dynamic conditions, it
enables itself (that is key bindings, lighter and such) and otherwise it
silently does nothing (no key bindings, lighter or whatever). Those
conditions go beyond simply tying it to certain major modes or alike.

Basically, it is a global minor mode w/ a snobbish attitude. ;)

I cannot get my head around it how to do this w/ define-minor-mode and
define-globalized-minor-mode.

Is this possible? Or am I going at it from the wrong angle and there is
a more Emacs/elisp idiomatic way to approach this kind of problem?

Thanks a lot in advance for each and every help. :)

So long,
Matthias

-- 
Dipl.-Inf. (FH) Matthias Dahl | Software Engineer | binary-island.eu
 services: custom software [desktop, mobile, web], server administration



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: conditionally enabling a mode in define-minor-mode context
  2014-05-11  8:50 conditionally enabling a mode in define-minor-mode context Matthias Dahl
@ 2014-05-11 19:30 ` Drew Adams
  2014-05-13 15:14   ` Matthias Dahl
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2014-05-11 19:30 UTC (permalink / raw
  To: Matthias Dahl, help-gnu-emacs

> I'm currently working on a new minor mode which requires that for every
> newly opened buffer/file which matches several dynamic conditions, it
> enables itself (that is key bindings, lighter and such) and otherwise it
> silently does nothing (no key bindings, lighter or whatever). Those
> conditions go beyond simply tying it to certain major modes or alike.
> 
> Is this possible?

Without thinking much about it, I'm guessing you could define two minor
modes, one of which you turn on everywhere and which controls the
conditional enabling of the other.  Again, just a thought, without
reflection - ignore if not helpful.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: conditionally enabling a mode in define-minor-mode context
  2014-05-11 19:30 ` Drew Adams
@ 2014-05-13 15:14   ` Matthias Dahl
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Dahl @ 2014-05-13 15:14 UTC (permalink / raw
  To: Drew Adams; +Cc: help-gnu-emacs

Hello Drew...

Thanks for taking the time. :)

> Without thinking much about it, I'm guessing you could define two minor
> modes, one of which you turn on everywhere and which controls the
> conditional enabling of the other.  Again, just a thought, without
> reflection - ignore if not helpful.

Hm... interesting. Never thought about that. Meanwhile I was thinking
about just doing everything manually instead of using the macro to
define a minor mode. This would give me the freedom to do what I want.

But having a "sentinel" minor mode that just checks and conditionally
activates the "real" minor mode, is also an interesting concept. I'll
need to think this through. Thanks.

The only reason for all of this: I want to make it as easy as possible
for users to use this minor mode w/o spending time fiddling with it and
w/o non-working key bindings (...) because the mode is in a "not working
with this buffer" state.

So long,
Matthias

-- 
Dipl.-Inf. (FH) Matthias Dahl | Software Engineer | binary-island.eu
 services: custom software [desktop, mobile, web], server administration



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-13 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-11  8:50 conditionally enabling a mode in define-minor-mode context Matthias Dahl
2014-05-11 19:30 ` Drew Adams
2014-05-13 15:14   ` Matthias Dahl

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.