From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "David PONCE" Newsgroups: gmane.emacs.devel,gmane.spam.detected Subject: Re: Suggestion: Simple way to make conditional key bindings. Date: Fri, 23 Aug 2002 14:52:10 +0200 (MET DST) Sender: emacs-devel-admin@gnu.org Message-ID: <41940.110413316$1030103804@news.gmane.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1030103804 29194 127.0.0.1 (23 Aug 2002 11:56:44 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 23 Aug 2002 11:56:44 +0000 (UTC) Cc: Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17iD3T-0007al-00 for ; Fri, 23 Aug 2002 13:56:43 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17iDWp-00019Q-00 for ; Fri, 23 Aug 2002 14:27:03 +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 17iD4f-0001CQ-00; Fri, 23 Aug 2002 07:57:57 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17iD2M-000195-00 for emacs-devel@gnu.org; Fri, 23 Aug 2002 07:55:34 -0400 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17iD2L-00018s-00 for emacs-devel@gnu.org; Fri, 23 Aug 2002 07:55:33 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17iCzG-0000YK-00 for emacs-devel@gnu.org; Fri, 23 Aug 2002 07:52:24 -0400 Original-Received: from smtp-out-6.wanadoo.fr ([193.252.19.25] helo=mel-rto6.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.10) id 17iCzG-0000Y8-00 for emacs-devel@gnu.org; Fri, 23 Aug 2002 07:52:22 -0400 Original-Received: from mel-rta7.wanadoo.fr (193.252.19.61) by mel-rto6.wanadoo.fr (6.5.007) id 3D6246E80013B7D4; Fri, 23 Aug 2002 13:52:11 +0200 Original-Received: from mail-web5 (193.252.19.156) by mel-rta7.wanadoo.fr (6.5.007) id 3D49FF140074EFAE; Fri, 23 Aug 2002 13:52:11 +0200 Original-Received: from '' by www.wanadoo.fr with HTTP; Original-To: X-TMDA-Confirmed: Fri Aug 23 07:55:33 EDT 2002 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: X-Spam-Report: 7.8 hits, 5 required; * 4.0 -- 'Message-Id' was added by a relay * 1.8 -- Message-Id is not valid, according to RFC-2822 * 0.4 -- BODY: Contains 'G.a.p.p.y-T.e.x.t' * 1.6 -- 'Message-Id' was added by a relay (2) Xref: main.gmane.org gmane.emacs.devel:6789 gmane.spam.detected:11863 X-Report-Unspam: http://unspam.gmane.org/gmane.emacs.devel:6789 Hi Kim, > Sometimes you would like a specific key binding to be controlled > by some global or local state, but you really don't want to mess > with minor-mode keymaps etc. > [...] > > One use would be to bind C-y to `yank' except when the first element > in the kill-ring is a table, in which case we want to run > `yank-with-properties': > > > (global-set-key "\C-y" > '(cond > ((and kill-ring (table-recognize-table (car kill-ring))) > yank-with-properties) > (t yank))) > > > 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. > > WDYT =3F It seems that you can do something similar this way: (global-set-key "\C-y" '(menu-item "my-filter" :filter my-filter)) (defun my-filter (&rest ignore) (cond ((and kill-ring (table-recognize-table (car kill-ring))) 'yank-with-properties) (t 'yank))) Am I wrong=3F Sincerely, David