From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Function for deleting a key binding in a sparse keymap Date: Thu, 08 Dec 2005 16:03:06 +0100 Message-ID: <43984B2A.6080205@student.lu.se> References: <3cc04a73cc1b1a.3cc1b1a3cc04a7@net.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1134062963 4021 80.91.229.2 (8 Dec 2005 17:29:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Dec 2005 17:29:23 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 08 18:29:19 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EkPYs-0008F9-I2 for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2005 18:28:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EkPZA-0003um-MJ for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2005 12:28:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EkNKN-0000fb-Nn for emacs-devel@gnu.org; Thu, 08 Dec 2005 10:04:59 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EkNKL-0000fE-KB for emacs-devel@gnu.org; Thu, 08 Dec 2005 10:04:59 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EkNIy-0000M2-CY for emacs-devel@gnu.org; Thu, 08 Dec 2005 10:03:32 -0500 Original-Received: from [81.228.11.98] (helo=pne-smtpout1-sn1.fre.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EkNK0-0001Cb-Hl for emacs-devel@gnu.org; Thu, 08 Dec 2005 10:04:36 -0500 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn1.fre.skanova.net (7.2.060.1) id 4396EEA40005CC8F; Thu, 8 Dec 2005 16:03:07 +0100 User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en Original-To: "Kim F. Storm" In-Reply-To: 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:47230 Archived-At: Kim F. Storm wrote: >LENNART BORGMAN writes: > > > >>>Why do you use emulation-mode-map-alist ? >>> >>> >>Because in this case it is a temporary minor mode that exists just >>during a few keystrokes. I actually put the keymap first in >>emulation-mode-map-alists to avoid any problem. Nearly all keys >>except those for using the mode are bound to a function that exits >>the temporary mode. >> >> > >That is NOT the purpose of emulation-mode-map-alists, and there must >be other ways to accomplish what you want to do. E.g. (not tested): > > (let (done) > (while (not done) > (let* ((ev (read-event)) > (cmd (lookup-key your-keymap ev))) > (if cmd > (call-interactively cmd) ; or just funcall > (setq done t) > (clear-this-command-keys t) > (setq unread-command-events (cons ev unread-command-events))))) > It seems more complicated to me, but I might be wrong just because I did not think of doing it this way. I am temporary using the emulation-mode-map-alists just for the purpose of putting my keymap first among the keymaps. This was not the reason for which emulation-mode-map-alist was invented, but it works for this purpose too I believe. I restore emulation-mode-map-alists when the temporary mode is exited. The temporary mode is a mode for resizing windows interactively (see http://ourcomments.org/Emacs/DL/elisp/bw-interactive.el). The user will do a few keystroke in this mode and then exit it. No keyboard commands except those for the mode are allowed. In post-command-hook I also do some checks to see if I should exit the temporary mode. (Maybe I should do more.) I am trying to understand what you are saying. Can you please explain what problems you see with what I am doing? I do not think that what I am doing here can possibly disturb the normal use of emulation-mode-map-alists, or can it? If it was not just before the release I might propose a new variable holding a temporary keymap like in my case, but this is not the time for it. Maybe what I am doing is unnecessary complicated?