From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mekeor Melire Newsgroups: gmane.emacs.bugs Subject: bug#74903: [PATCH] Add function to show table of keys when describing keymap variable Date: Sun, 15 Dec 2024 23:14:15 +0000 Message-ID: <87v7vktu7s.fsf@posteo.de> 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="18897"; mail-complaints-to="usenet@ciao.gmane.io" To: 74903@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 16 00:15:38 2024 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 1tMxpp-0004l8-MI for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Dec 2024 00:15:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMxpJ-0007Tl-6Z; Sun, 15 Dec 2024 18:15:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMxpH-0007Ry-9M for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 18:15:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMxpH-0004el-0i for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 18:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=UzsONn8FBco9a/7iXS4OMXzAwOQnNZPUhTQJuLajg9A=; b=lLbnbL8XAFEQQtb9HgPx6bK/8mFgpf1aTvuwhDbEnL43A3g/znfCvIyvUYEpqBPDVNm+yAvdr8Sjf5fzln4n+xkUz2pyem2BhcjPa0ha/pFAxFEaOSPyx6yYIIbW0GVo9x7cUShRyvK+Nb2mLBTGUOeAkOj3AoaB9irWwt4btlrM76VLiv7kB6AE5nQqpIYFSaGtJM8ZUSpaeVIV2/gLH/0p/4VLrEBw8KPfwSRepDP9o53FtUmdICHXwkwFLLghTa2Jr6KtYd1qro2Gi1QouC4+aa8LyGXi9v+mrFw4AdwwM3p9Qa/xm4FpqGcFabx+cHuAq/RPl87GPJLVQ1FkHg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tMxpG-00010i-R1 for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 18:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mekeor Melire Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 23:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74903 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.17343044983851 (code B ref -1); Sun, 15 Dec 2024 23:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Dec 2024 23:14:58 +0000 Original-Received: from localhost ([127.0.0.1]:52589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMxp6-0000zz-W8 for submit@debbugs.gnu.org; Sun, 15 Dec 2024 18:14:58 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMxp5-0000zq-Ed for submit@debbugs.gnu.org; Sun, 15 Dec 2024 18:14:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMxp4-0007R8-57 for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 18:14:50 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMxoy-0004bB-R0 for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 18:14:49 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 37685240027 for ; Mon, 16 Dec 2024 00:14:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1734304477; bh=qJAq2OniCTWTAzXD13lc0nYhr0+UVdOfT24g7M7ugzE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=D87jyFNGoFxDAmvduW1/j1GgZ72L/DmpvsoWhAdF2+a0492McjdShu2tIeRQ+wwVS xUF/nEhXLyjKeb1rnANlY00JYDfvu0edG3U6du9gROR73hM1H18lswLlEuAdCowGjx y607hXN8stIZeDPnShTm9aKr2pRQJtB1BR89Vbg8eugTPMIiKnO3UUjfDAlQmMYMcz PM1wSbYP/TiDCbUIYdRjplrIXQ82+cOvMbctxvCwguxfR5hq5V/vIcVJNyJBieXX9+ nslPKEwsJriQrqBUJa6UHRBaDbUl7tTmsrV5y3pRq3S5kqyWvp0uAbNtZHWRdcSFJs +H6vpANzuRRgA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YBJn85BcSz9rxB; Mon, 16 Dec 2024 00:14:36 +0100 (CET) Received-SPF: pass client-ip=185.67.36.65; envelope-from=mekeor@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297144 Archived-At: --=-=-= Content-Type: text/plain Tags: patch It'd be nice if users could opt in to have C-h v some-map RET show a nice table of key bindings for that keymap. I wrote a function that can be added to help-fns-describe-variable-functions so that this happens. What do you think? Alternatively, we can also add a key binding to help-mode so that users can easily "switch" from describe-variable to describe-keymap, e.g. per "K": C-h v message-mode-map RET K --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-function-to-show-table-of-keys-when-describing-k.patch >From df0fbd4d61a0d0bebcb050f4f22a5ae4c67d0f65 Mon Sep 17 00:00:00 2001 From: Mekeor Melire Date: Sun, 15 Dec 2024 23:21:00 +0100 Subject: [PATCH] Add function to show table of keys when describing keymap variable * lisp/help-fns.el (help-fns-keymap-key-bindings): New function possible member of 'help-fns-describe-variable-functions' that shows a table of key bindings. * etc/NEWS: Advertise it. --- etc/NEWS | 12 ++++++++++++ lisp/help-fns.el | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 48546a2d916..9ae50ddb923 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -220,6 +220,18 @@ on the header lines are now these two: the selected window uses ** In 'customize-face', the "Font family" attribute now supports completion. +** Help + ++++ +*** New function 'help-fns-keymap-key-bindings'. +This function inserts into the current buffer a table of key bindings if +the given argument is a variable with a keymap as value. If you want +'describe-variable' ('C-h v') to insert a table of key bindings into +regular "*Help*" buffers, add the following to your init file: + + (add-hook 'help-fns-describe-function-functions + #'help-fns-keymap-key-bindings) + * Editing Changes in Emacs 31.1 diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 157ec6b8d61..4ed4c64f3ea 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -563,6 +563,16 @@ find-lisp-object-file-name (src-file (locate-library file-name t nil 'readable))) (and src-file (file-readable-p src-file) src-file)))))) +(defun help-fns-keymap-key-bindings (variable) + "Insert table of key bindings of keymap VARIABLE into the current buffer. +You can add this function to the `help-fns-describe-function-functions' +hook to show examples of using FUNCTION in *Help* buffers produced by +\\[describe-function]." + (when-let* ((value (symbol-value variable)) + ((keymapp value))) + (with-current-buffer standard-output + (help--describe-map-tree value)))) + (defun help-fns--key-bindings (function) (when (commandp function) (let ((pt2 (with-current-buffer standard-output (point))) -- 2.47.1 --=-=-=--