From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Function for deleting a key binding in a sparse keymap Date: Mon, 05 Dec 2005 14:42:26 -0500 Message-ID: References: <439382B9.7020802@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1133811920 30057 80.91.229.2 (5 Dec 2005 19:45:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 5 Dec 2005 19:45:20 +0000 (UTC) Cc: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 05 20:45:19 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EjMEi-0003bY-7v for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2005 20:42:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EjMEr-0005E4-2C for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2005 14:43:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EjMEV-0005Dx-NI for emacs-devel@gnu.org; Mon, 05 Dec 2005 14:42:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EjMEU-0005De-TN for emacs-devel@gnu.org; Mon, 05 Dec 2005 14:42:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EjMEU-0005DY-M2 for emacs-devel@gnu.org; Mon, 05 Dec 2005 14:42:42 -0500 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EjMF2-0006vm-J4 for emacs-devel@gnu.org; Mon, 05 Dec 2005 14:43:16 -0500 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 50CAF2CF6CB; Mon, 5 Dec 2005 14:42:32 -0500 (EST) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id C4B694AC00A; Mon, 5 Dec 2005 14:42:26 -0500 (EST) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 94B12E6C1F; Mon, 5 Dec 2005 14:42:26 -0500 (EST) Original-To: Lennart Borgman In-Reply-To: <439382B9.7020802@student.lu.se> (Lennart Borgman's message of "Mon, 05 Dec 2005 00:58:49 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-4.852, requis 5, autolearn=not spam, AWL 0.05, BAYES_00 -4.90) X-MailScanner-From: monnier@iro.umontreal.ca 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:47018 Archived-At: > It would be good to have a function like this in Emacs: > (defun delete-key-in-sparse-map(sparse-map key) > "In the sparse keymap SPARSE-MAP remove KEY. > In a sparse keymap if a key is bound to nil that means that > invoking that key find no binding in that map. If instead there > is no binding at all then the default value if any in that keymap > is used. This function removes any binding of KEY in the sparse > keymap SPARSE-MAP so that the default value will be used. > If SPARSE-MAP is not a sparse keymap an error is raised." > ... > ) > However I do not know how to implement this for different formats for > specifying the key. There is no reason to limit this to sparse keymaps. AFAIK the problem that a sparse keymap had all keys bound to nil has been solved. It seems that I forgot to update the corresponding documentation. I've just installed the patch below. Stefan --- keymaps.texi 22 ao=FB 2005 10:23:52 -0400 1.68 +++ keymaps.texi 05 d=E9c 2005 14:38:12 -0500=09 @@ -158,17 +158,6 @@ bindings. A keymap with such a char-table is called a @dfn{full keymap}. Other keymaps are called @dfn{sparse keymaps}. =20 -When a keymap contains a char-table vector, it always defines a -binding for each character without modifiers. However, if the binding -is @code{nil}, it doesn't constitute a definition. @code{nil} takes -precedence over a default binding or a binding in the parent keymap. -So in a full keymap, default bindings are not meaningful for -characters without modifiers. They can still apply to characters with -modifier bits and to non-character events. A binding of @code{nil} -does @emph{not} override lower-precedence keymaps; thus, if the local -map gives a binding of @code{nil}, Emacs uses the binding from the -global map. - @item @var{string} @cindex keymap prompt string @cindex overall prompt string @@ -178,6 +167,13 @@ use the keymap as a menu. @xref{Defining Menus}. @end table =20 +When the binding is @code{nil}, it doesn't constitute a definition +but it does take precedence over a default binding or a binding in the +parent keymap. On the other hand, a binding of @code{nil} does +@emph{not} override lower-precedence keymaps; thus, if the local map +gives a binding of @code{nil}, Emacs uses the binding from the +global map. + @cindex meta characters lookup Keymaps do not directly record bindings for the meta characters. Instead, meta characters are regarded for purposes of key lookup as