From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: M-g in dired Date: Tue, 01 Nov 2005 11:16:43 +0200 Organization: JURTA Message-ID: <8764rcye8k.fsf@jurta.org> References: <873bnf36mr.fsf@jurta.org> <878xwap86u.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1130844168 15122 80.91.229.2 (1 Nov 2005 11:22:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2005 11:22:48 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 01 12:22:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EWuDJ-00041P-KT for ged-emacs-devel@m.gmane.org; Tue, 01 Nov 2005 12:22:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWuDI-0003P3-2V for ged-emacs-devel@m.gmane.org; Tue, 01 Nov 2005 06:22:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EWtdH-0003N9-Bd for emacs-devel@gnu.org; Tue, 01 Nov 2005 05:44:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EWtZg-0002sf-FA for emacs-devel@gnu.org; Tue, 01 Nov 2005 05:41:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWsYd-00009s-Hy for emacs-devel@gnu.org; Tue, 01 Nov 2005 04:35:56 -0500 Original-Received: from [194.126.101.111] (helo=mail.neti.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EWsYc-0002hu-EY; Tue, 01 Nov 2005 04:35:54 -0500 Original-Received: from mail.neti.ee (80-235-34-45-dsl.mus.estpak.ee [80.235.34.45]) by Relayhost1.neti.ee (Postfix) with ESMTP id 6103F30E4; Tue, 1 Nov 2005 11:36:05 +0200 (EET) Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Mon, 31 Oct 2005 21:13:35 -0500") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-2.2.1 (20041222) (Debian) at neti.ee 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:45228 Archived-At: > Would you like to try modifying that code so it detects the other case? I think the most appropriate place to modify is `shadow_lookup'. The second part of the patch below changes it to return nil when one of prefix keys is found in the keymap with higher priority. This allows to find a shorter key in the local keymap rather than in the global keymap. For example, looking for "M-g n" in two keymaps (lookup-key dired-mode-map [134217831 110]) => 1 (lookup-key global-map [134217831 110]) => next-error will return nil, because lookup-key in dired-mode-map returns a number, since "M-g" in dired-mode-map is bound to `dired-goto-file'. However, this change also requires one change in the value returned by `lookup-key'. Currently, it returns a number even when it can't find a key definition and the tested key sequence is two keys or longer. So, for example, in dired-mode-map where "C-x `" is undefined, `lookup-key' returns 1: (lookup-key dired-mode-map [24 96]) => 1 It seems this is not correct. And the documentation says nothing about such case. The first part of the patch changes `lookup-key' to return nil, e.g.: (lookup-key dired-mode-map [24 96]) => nil I can't estimate if there is a code that relies on the current return value of `lookup-key'. If so, then perhaps a new special argument could be added to `lookup-key' to change the semantic of the return value? Index: src/keymap.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/keymap.c,v retrieving revision 1.307 diff -c -r1.307 keymap.c *** src/keymap.c 12 Sep 2005 10:26:35 -0000 1.307 --- src/keymap.c 1 Nov 2005 09:16:18 -0000 *************** *** 1262,1269 **** keymap = get_keymap (cmd, 0, 1); if (!CONSP (keymap)) ! RETURN_UNGCPRO (make_number (idx)); ! QUIT; } } --- 1262,1273 ---- keymap = get_keymap (cmd, 0, 1); if (!CONSP (keymap)) ! { ! if (!NILP (cmd)) ! RETURN_UNGCPRO (make_number (idx)); ! else ! return Qnil; ! } QUIT; } } *************** *** 2377,2383 **** for (tail = shadow; CONSP (tail); tail = XCDR (tail)) { value = Flookup_key (XCAR (tail), key, flag); ! if (!NILP (value) && !NATNUMP (value)) return value; } return Qnil; --- 2381,2389 ---- for (tail = shadow; CONSP (tail); tail = XCDR (tail)) { value = Flookup_key (XCAR (tail), key, flag); ! if (NATNUMP (value)) ! return Qnil; ! if (!NILP (value)) return value; } return Qnil; -- Juri Linkov http://www.jurta.org/emacs/