From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: A simple implementation of context-sensitive keys Date: Fri, 12 Sep 2008 08:58:02 +0200 Message-ID: <87abed97gl.fsf@thinkpad.tsdh.de> References: <87y72079mg.fsf@thinkpad.tsdh.de> <87d4jbg62j.fsf@thinkpad.tsdh.de> <48C92024.6080804@gmail.com> <48C921CB.3010700@gmail.com> <87hc8miwy0.fsf@thinkpad.tsdh.de> <48C981C6.9030201@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221202837 28211 80.91.229.12 (12 Sep 2008 07:00:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Sep 2008 07:00:37 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: "Lennart Borgman \(gmail\)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 12 09:01:33 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 1Ke2eq-0006Qe-Te for ged-emacs-devel@m.gmane.org; Fri, 12 Sep 2008 09:01:33 +0200 Original-Received: from localhost ([127.0.0.1]:41818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ke2dq-0000Sa-Bk for ged-emacs-devel@m.gmane.org; Fri, 12 Sep 2008 03:00:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ke2dl-0000SL-NS for emacs-devel@gnu.org; Fri, 12 Sep 2008 03:00:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ke2dj-0000S9-SE for emacs-devel@gnu.org; Fri, 12 Sep 2008 03:00:24 -0400 Original-Received: from [199.232.76.173] (port=60991 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ke2dj-0000S1-Jl for emacs-devel@gnu.org; Fri, 12 Sep 2008 03:00:23 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:29501) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ke2di-0006mf-Vj for emacs-devel@gnu.org; Fri, 12 Sep 2008 03:00:23 -0400 Original-Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ke2dh-0005vW-SH for emacs-devel@gnu.org; Fri, 12 Sep 2008 03:00:21 -0400 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 3CD14160DE2; Fri, 12 Sep 2008 03:00:21 -0400 (EDT) Original-Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 12 Sep 2008 03:00:21 -0400 X-Sasl-enc: 486jvHYalu1a3e2KLNJ7/Kd6CwFTldsYmNGf86oVR4C4 1221202809 Original-Received: from thinkpad.tsdh.de (p54AF2367.dip0.t-ipconnect.de [84.175.35.103]) by mail.messagingengine.com (Postfix) with ESMTPA id B96E5BA19; Fri, 12 Sep 2008 03:00:08 -0400 (EDT) Mail-Copies-To: never Mail-Followup-To: "Lennart Borgman \(gmail\)" , Stefan Monnier , emacs-devel@gnu.org In-Reply-To: <48C981C6.9030201@gmail.com> (Lennart Borgman's message of "Thu, 11 Sep 2008 22:38:30 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by mx20.gnu.org: Genre and OS details not recognized. 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:103838 Archived-At: "Lennart Borgman (gmail)" writes: Hi Lennart, >> So I guess a first step into the right direction would be to enhance >> `describe-key' that it doesn't stop if KEY is found, but to list the >> shadowed commands, too. Something like > > If you say that this is the first step so, yes ... ;-) > >> ,---- >> | TAB (translated from ) runs the command message-tab, which is an >> | interactive compiled Lisp function in >> | `/usr/share/emacs/23.0.60/lisp/gnus/message.el'. >> | >> | It is bound to TAB in `message-mode-map'. <== This is new > > There is currently no function in Emacs to find the keymap variable > name. I think you could reimplement the key lookup procedure you referenced and don't stop searching when KEY is found. Then you know the name of the map. > However I wrote the command `describe-key-and-map-briefly' that tries > to find the keymap variable name. This is a bit tricky and I am sure > that you can construct cases where it does not work. However so far I > have not found any example where it does not work. Hey cool. Here's a function to find all commands bound to key. The car is the command which is executed, the cdr is the list of shadowed commands. --8<---------------cut here---------------start------------->8--- (defun lookup-key-bindings (key) (let (list) (dolist (map (current-active-maps)) (let ((cmd (lookup-key map key))) (when (and cmd (not (numberp cmd))) (add-to-list 'list cmd t)))) list)) (lookup-key-bindings (kbd "C-f")) ;; ==C-j==> (paredit-forward forward-char) --8<---------------cut here---------------end--------------->8--- So we have to combine those functions and are done. ;-) Bye, Tassilo