From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Suggestion: Simple way to make conditional key bindings. Date: Sun, 25 Aug 2002 18:36:28 -0600 (MDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200208260036.g7Q0aSR12388@wijiji.santafe.edu> References: <5x4rdlbx1i.fsf@kfs2.cua.dk> Reply-To: rms@gnu.org NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1030322480 26585 127.0.0.1 (26 Aug 2002 00:41:20 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 26 Aug 2002 00:41:20 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17j7wT-0006ug-00 for ; Mon, 26 Aug 2002 02:41:17 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17j8R3-0002td-00 for ; Mon, 26 Aug 2002 03:12:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17j7xl-0002wW-00; Sun, 25 Aug 2002 20:42:37 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17j7rt-0001Nn-00 for emacs-devel@gnu.org; Sun, 25 Aug 2002 20:36:33 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17j7rq-0001Mq-00 for emacs-devel@gnu.org; Sun, 25 Aug 2002 20:36:32 -0400 Original-Received: from pele.santafe.edu ([192.12.12.119]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17j7rq-0001MN-00; Sun, 25 Aug 2002 20:36:30 -0400 Original-Received: from wijiji.santafe.edu (wijiji [192.12.12.5]) by pele.santafe.edu (8.11.6+Sun/8.11.6) with ESMTP id g7Q0as510190; Sun, 25 Aug 2002 18:36:54 -0600 (MDT) Original-Received: (from rms@localhost) by wijiji.santafe.edu (8.11.6+Sun/8.9.3) id g7Q0aSR12388; Sun, 25 Aug 2002 18:36:28 -0600 (MDT) X-Authentication-Warning: wijiji.santafe.edu: rms set sender to rms@wijiji using -f Original-To: storm@cua.dk In-Reply-To: <5x4rdlbx1i.fsf@kfs2.cua.dk> (storm@cua.dk) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:6887 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:6887 (global-set-key [f11] '(cond (a delete-char) (b find-file) (c nil) (t (keymap (?a . "abc") (?b . "bcd"))))) I agree that this is convenient. The question is, is it better to make this a primitive facility, as you suggested, or to add a macro to do the job using menu-item, as Stefan suggested? Using menu-item has an advantage that we use a function rather than a form. It also has the advantage of not adding any complexity to the key binding data structures. But those are not the only factors; others may be more important. One advantage (IMO) is that C-h k C-y will report yank or yank-with-properties depending on the actual function taken if you hit C-y. If we use menu-item, what will C-h c say? One problem with your change is "what binding do we use when we don't want to run code?". The `menu-item' syntax provides a binding (in the example above it's "my-filter" which is not very useful indeed) for the case where code should not be evalled (for example in `where-is'). I think we do want where-is to find this binding, though. (define-key global-map "\C-y" 'yank-careful) (defun yank-careful (...) "Reinsert the last stretch of killed text, like `yank'. Contrary to `yank' this function is careful to preserve some important text properties when yanking tables." ...) The advantage is that C-h k C-y doesn't just give you one of the two bindings but a docstring that describes both. I think that sometimes this will be better, but sometimes it will be better for C-h k to give the doc string for the specific command that will be executed.