[Top][All Lists]

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

Re: A simple implementation of context-sensitive keys

From: Ted Zlatanov
Subject: Re: A simple implementation of context-sensitive keys
Date: Wed, 10 Sep 2008 11:43:30 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

On Wed, 10 Sep 2008 12:57:56 +0200 Tassilo Horn <address@hidden> wrote: 

TH> (defmacro define-context-key (mode key predicate function)
TH>   "Bind KEY in MODE's map to a command which calls FUNCTION if PREDICATE is 

TH> If PREDICATE doesn't match and KEY is normally bound in MODE, the
TH> corresponding default command will be executed.

TH> If KEY isn't normally bound in MODE, MODE will be disabled
TH> temporally (to prevent an infinite recursion) and the function
TH> which is then bound to KEY will be called."

I think this is a great idea, but it seems like it's pulling the
different ways a bound function can operate internally to the higher
level, complicating what the user has to write.  IOW, you can do the
same inside FUNCTION by testing a series of PREDICATEs.  It does
abstract the more tedious stuff, but maybe that can be a macro inside
the function itself, e.g.

(defun my-bound-function ()
   (run-in-context outline-minor-mode outline-context-p outline-toggle-children)
   (run-in-context outline-minor-mode eolp self-insert-command)))

This lets the function do more complex things, not just a cond which the
top-level approach is essentially.

I don't know if this can be considered as an alternative.  It's nice
syntactic sugar, for sure.  I've done it the long way several times so I
would welcome anything to make it easier.


reply via email to

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