From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#55393: describe-keymap: suggest symbol at point Date: Fri, 13 May 2022 10:54:12 +0530 Message-ID: <87lev60zur.fsf@gmail.com> References: <87pmki13i2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2475"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 55393@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 13 07:25:34 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npNny-0000V5-7I for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 May 2022 07:25:34 +0200 Original-Received: from localhost ([::1]:37396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npNnx-0000KF-0P for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 May 2022 01:25:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npNnS-0000K0-Pq for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 01:25:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npNnS-00009w-Gb for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 01:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1npNnS-0008VY-B0 for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 01:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 May 2022 05:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 55393-submit@debbugs.gnu.org id=B55393.165241948832678 (code B ref 55393); Fri, 13 May 2022 05:25:02 +0000 Original-Received: (at 55393) by debbugs.gnu.org; 13 May 2022 05:24:48 +0000 Original-Received: from localhost ([127.0.0.1]:42749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npNnD-0008Uw-JK for submit@debbugs.gnu.org; Fri, 13 May 2022 01:24:48 -0400 Original-Received: from mail-pf1-f195.google.com ([209.85.210.195]:43686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npNn9-0008Ug-6d for 55393@debbugs.gnu.org; Fri, 13 May 2022 01:24:45 -0400 Original-Received: by mail-pf1-f195.google.com with SMTP id d25so6731543pfo.10 for <55393@debbugs.gnu.org>; Thu, 12 May 2022 22:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=P/p306Tb7Ksr6iksoLT7//KUXJvJ2O2nKE8I9qzmFFs=; b=RItkBzoAZUlc6VOg+J/Ydnae5MIaaYNOGCtVZcpJDm93tsG+jooPx3NLlXw2Mm+KHE RvrTCGuNC2AZZ3QwaPGHeDxXi61nVPW5j/ZjkPEfMmlUhyDhNocsp6mmPtkSmnj6itTW K1dm3UGQYn7+Ksfl/uPOcRLABpf3uMjPZ6X6eEQOyBcEPe9Ft5REqDvV3rmx8pzm1kUv i4D5WHJKy6qQOCbJG6238cP8ykkKZXmrZqwECM5hVDr5NmUwDGshANXEnm6zqxqQ89PZ jlVULv5iZ99c6l4HlyekOuUruHuC2TpAweQmeoy1KaEFvLM5PaU1gCiDAcvH+k5h0X+p Le2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=P/p306Tb7Ksr6iksoLT7//KUXJvJ2O2nKE8I9qzmFFs=; b=QonnksLSitv+NW9lRL+loy+YZCfWQGpQEwKMZepuCtl4Y4bANmc+4+Sz3Jy5QBRADB 9juqavPv17KBnC/zyji6sqSGTg8B9wh2w1gIUxtQFiQzL4l77Dyj5Ic3PpIeEuUPNNRL AAOCPGAig8Kw134NEm99140yhLeuk782CFP+E9+IvgwieN00MWr32Lu3pUcVxyG5ny8T cIYkG05zrEJlgYJtSkysAuRwZYpVXO2mAmjmpl9rVoMKt3T+xYLdRPS3f9NkMZglVT5H RdrHduwuIYbP4oEbC8J4VDe2NNM2fweuXJdnEwK8Oj/LjBZDGDd81R9EXw8pRcRUG67K Lfuw== X-Gm-Message-State: AOAM530NoIBWxxmmobS1J0KizoPaGPZ1Ad+mmtRv31cCWam7TfS0BU8V OaA9UAH4CddPqPfAq113AReRg5jorQg= X-Google-Smtp-Source: ABdhPJwpr43h+gBW70zC8oVxLOLItSE536++GD+Zd8IG4D4KMj8v1tJ0rlCfHbzZqBzkpgAewXNDpQ== X-Received: by 2002:a63:8848:0:b0:3ab:2967:df83 with SMTP id l69-20020a638848000000b003ab2967df83mr2574921pgd.77.1652419476979; Thu, 12 May 2022 22:24:36 -0700 (PDT) Original-Received: from localhost ([49.204.118.33]) by smtp.gmail.com with ESMTPSA id p9-20020a170902780900b0015e8d4eb294sm91139pll.222.2022.05.12.22.24.35 for <55393@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 22:24:36 -0700 (PDT) In-Reply-To: <87pmki13i2.fsf@gmail.com> (Visuwesh's message of "Fri, 13 May 2022 09:35:25 +0530") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:232106 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=B5=E0=AF=86=E0=AE=B3=E0=AF=8D=E0=AE=B3=E0=AE=BF =E0=AE=AE=E0=AF=87 = 13, 2022] Visuwesh wrote: > Tags: patch > > describe-keymap differs from other describe-* commands in that it does > not suggest the symbol at point which always annoyed me. This patch > makes describe-keymap consider the symbol at point first. > > [ I hope it is okay to use if-let family of macros in these files now? ] > > > > > In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo vers= ion 1.16.0, Xaw scroll bars) > Repository revision: ca3858563c7ba8ee3caa82fbd2b7c386ea60c0d3 > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 > System Description: NixOS 21.11 (Porcupine) > > Configured using: > 'configure > --prefix=3D/nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-2022022= 5.0 > --disable-build-details --with-modules --with-x-toolkit=3Dlucid > --with-xft --with-cairo --with-native-compilation' Turns out I did not git pull master properly so that patch was against an old master. Updated patch attached here, --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-describe-keyap-Suggest-symbol-at-point.patch >From 1911ea3d4963bc945953886fb625db6c838f19cb Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Fri, 13 May 2022 10:52:09 +0530 Subject: [PATCH] describe-keyap: Suggest symbol at point * lisp/help-fns.el (help-fns--most-relevant-active-keymap): Suggest the symbol at point if it is a keymap. * etc/NEWS: Announce the change. --- etc/NEWS | 5 +++++ lisp/help-fns.el | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index e09834c..54647b8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -562,6 +562,11 @@ minor modes are listed after the major mode. The apropos commands will now select the apropos window if 'help-window-select' is non-nil. +--- +*** 'describe-keymap' now considers the symbol at point +'describe-keymap' suggests the symbol at point as the default candidate +if it is a keymap. + ** Outline Mode +++ diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 927a4f0..2636ba9 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1884,16 +1884,21 @@ variable with value KEYMAP." The heuristic to determine which keymap is most likely to be relevant to a user follows this order: -1. 'keymap' text property at point -2. 'local-map' text property at point -3. the `current-local-map' +1. symbol at point +2. 'keymap' text property at point +3. 'local-map' text property at point +4. the `current-local-map' This is used to set the default value for the interactive prompt in `describe-keymap'. See also `Searching the Active Keymaps'." - (help-fns-find-keymap-name (or (get-char-property (point) 'keymap) - (if (get-text-property (point) 'local-map) - (get-char-property (point) 'local-map) - (current-local-map))))) + (if-let ((sym (symbol-at-point)) + (sym (when sym (intern-soft sym))) + (keymapp (ignore-errors (symbol-value sym)))) + sym + (help-fns-find-keymap-name (or (get-char-property (point) 'keymap) + (if (get-text-property (point) 'local-map) + (get-char-property (point) 'local-map) + (current-local-map)))))) (defvar keymap-name-history nil "History for input to `describe-keymap'.") -- 2.33.1 --=-=-=--