From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: A simple implementation of context-sensitive keys Date: Wed, 10 Sep 2008 11:43:30 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86iqt42bpp.fsf@lifelogs.com> References: <87y72079mg.fsf@thinkpad.tsdh.de> <48C7A31A.3000500@gmail.com> <87hc8o6zez.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221065247 24702 80.91.229.12 (10 Sep 2008 16:47:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Sep 2008 16:47:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 10 18:48:22 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KdSpa-0000j5-JD for ged-emacs-devel@m.gmane.org; Wed, 10 Sep 2008 18:46:14 +0200 Original-Received: from localhost ([127.0.0.1]:42259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdSoa-0005rx-7w for ged-emacs-devel@m.gmane.org; Wed, 10 Sep 2008 12:45:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KdSnK-0005PJ-6G for emacs-devel@gnu.org; Wed, 10 Sep 2008 12:43:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KdSnJ-0005Ob-9O for emacs-devel@gnu.org; Wed, 10 Sep 2008 12:43:53 -0400 Original-Received: from [199.232.76.173] (port=60669 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdSnI-0005OL-Ts for emacs-devel@gnu.org; Wed, 10 Sep 2008 12:43:53 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:52272 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KdSnI-0001gx-DD for emacs-devel@gnu.org; Wed, 10 Sep 2008 12:43:52 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KdSnB-0003dd-6r for emacs-devel@gnu.org; Wed, 10 Sep 2008 16:43:45 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Sep 2008 16:43:45 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Sep 2008 16:43:45 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:VVvOYroZUsO6VpLj9dJXXF0XboA= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:103773 Archived-At: On Wed, 10 Sep 2008 12:57:56 +0200 Tassilo Horn 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 non-nil. 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 () (or (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. Ted