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 09:35:25 +0530 Message-ID: <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="10623"; mail-complaints-to="usenet@ciao.gmane.io" 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 06:07:30 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 1npMaP-0002as-GD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 May 2022 06:07:29 +0200 Original-Received: from localhost ([::1]:52632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npMaN-000261-Oj for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 May 2022 00:07:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npMZ0-0000Un-9b for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 00:06:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npMYz-0006eT-Vs for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 00:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1npMYz-00068G-R8 for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 00:06:01 -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 04:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165241475623549 (code B ref -1); Fri, 13 May 2022 04:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 May 2022 04:05:56 +0000 Original-Received: from localhost ([127.0.0.1]:42688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npMYu-00067k-Cz for submit@debbugs.gnu.org; Fri, 13 May 2022 00:05:56 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npMYs-00067c-H3 for submit@debbugs.gnu.org; Fri, 13 May 2022 00:05:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npMYs-0000LU-C5 for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 00:05:54 -0400 Original-Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:37393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npMYq-0006dx-Id for bug-gnu-emacs@gnu.org; Fri, 13 May 2022 00:05:54 -0400 Original-Received: by mail-pj1-x1042.google.com with SMTP id t11-20020a17090ad50b00b001d95bf21996so9706613pju.2 for ; Thu, 12 May 2022 21:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=TJFUkXjsmIvnLD3YGpjNxAw/ddtif7ib07xu9M2rWkQ=; b=bGlZHnnxkSJ6CzoA52CHy2dTva/QikIOfKjGTlbI4XEqpeUNBlj/GhKTTHf/2lYhrK P/kdMYx/aBj2eHWUYwNYZ9Ok23r7IN515FZPJmeVUSDrygxxBT03QZLps/BRYzj6frEm JdwY3qo3QODfiYFI8/WhKvQLJjjPDYu5uR+cpny4Y/ebXGsLDRIi7JLyhb1lA2Isljff x1jO/PHHLU2iIV9o7JbtHQ0poBC5P3nOhr8CKCgTyWXxyJbDD+q0zL9nzMK3clyUKmjq 4I8MOrChMlSwxZL/QlWty6XN7Hud3FiXNj/Xdyh+LmQiwSGtTzYISItlMVKGtT8qXXeE TRaA== 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:date:message-id:mime-version; bh=TJFUkXjsmIvnLD3YGpjNxAw/ddtif7ib07xu9M2rWkQ=; b=TZrumVcu2z4/lMRLd0UsX+M6ReVAEn9Y+QRu4PEy+JMNY2/u/Y0B7aMCkNGVlWicpX QbwUIOrFj+FxNZqlUXYx5u71PVVVry4VK3jYgVpRfOK4tnNcqbbnnCMFHNJSUCQ/pUO8 XXlLhz5KoZv+OKs0KOTa2Ev9jeLh+utSh6Fi8CEC1ZK8Zky8aMdAOAtimWuliTh+imi9 aPIPx2+1OYQPvtrjedB/bjcWWGwlCdVSTyulkh4JXr4BuwVAtErlYaoNOvvqxZYSxdKf QKx2491UV0NxLqumF4nn9X/F+SmYjXDY8M+B+SKT2jQXByH3SEe2/B71HUwvXTOPfOhY JaKQ== X-Gm-Message-State: AOAM532QRTGLNF3cDrF82qINhlhG/PuwfNAc5rITiGiouUzhFicjSpwM /IyeW4ZoWkwg9KG/NjCvlN//AGgtKog= X-Google-Smtp-Source: ABdhPJw693U4Zgr7atTr9rZH0xCbOQYvQ9MP7YhbNol9jCzHcJ+5BAkVuSnj20pZXXrvq4++s7Cdkg== X-Received: by 2002:a17:902:db05:b0:15e:b542:3f23 with SMTP id m5-20020a170902db0500b0015eb5423f23mr3028102plx.143.1652414750502; Thu, 12 May 2022 21:05:50 -0700 (PDT) Original-Received: from localhost ([49.204.118.33]) by smtp.gmail.com with ESMTPSA id p187-20020a625bc4000000b0050dc76281basm611148pfb.148.2022.05.12.21.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 21:05:49 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=visuweshm@gmail.com; helo=mail-pj1-x1042.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:232105 Archived-At: --=-=-= Content-Type: text/plain 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? ] --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-describe-keymap-Suggest-symbol-at-point.patch >From 84dbe9924269c2c5e2fb73aadc82536e48e81820 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Fri, 13 May 2022 09:20:18 +0530 Subject: [PATCH] describe-keymap: 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 | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 273fa77640..251ebc46ce 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -363,6 +363,11 @@ These will take you (respectively) to the next and previous "page". This will take you to the Emacs Lisp manual entry for the item displayed, if any. +--- +*** '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 *** Support for customizing the default visibility state of headings. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 80d7d5cb02..3836cc7367 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1779,16 +1779,21 @@ help-fns--most-relevant-active-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) + (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))))) + (current-local-map)))))) (defvar keymap-name-history nil "History for input to `describe-keymap'.") -- 2.33.1 --=-=-= Content-Type: text/plain In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 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=/nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0 --disable-build-details --with-modules --with-x-toolkit=lucid --with-xft --with-cairo --with-native-compilation' --=-=-=--