emacs-devel
[Top][All Lists]
Advanced

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

Re: A simple implementation of context-sensitive keys


From: Lennart Borgman (gmail)
Subject: Re: A simple implementation of context-sensitive keys
Date: Wed, 10 Sep 2008 12:36:10 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

Tassilo Horn wrote:
> Hi all,
> 
> to get the full power out of emacs, I use quite a lot of different minor
> modes with a ton of home-brewn functions.  To make them quickly
> accessible, I've bound them to some key.  But "good" keys are rare, and
> so I started writing special dispatching commands which DTRT dependend
> on the context they're used in.  But that's quite cumbersome, because
> ideally you have to recognize each command which would normally be bound
> to the key, too.
> 
> So I've come up with this macro, which creates such a dispatching
> command automagically.  If none of the context predicates match, the
> default command bound to the key will be executed.
> 
> --8<---------------cut here---------------start------------->8---
> (defmacro define-context-key (mode key preds-funs)
>   "Bind KEY to an anonymous dispatching command in MODE.
> PREDS-FUNS is an alist with elements of the form


Hi Tassilo

I think there are a number of packages out there doing quite similar
things: smart-tab, tabkey2, hippi-expand.

Those are all focused on completion, but that is more a conceptual focus
(which I think is good). By default they bind the Tab key (which you
also did in your example). Maybe it would be good to generalize that as
you did here.

In tabkey2.el (did you notice it when I sent it to this list?) I have
tried to write the supporting functions needed to make the key bindings
transparent to the user. You are welcome to contribute to it if you want
too. The latest version is always in nXhtml on Launchpad.

BTW Yasnippet is a kind of completion function.




reply via email to

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