From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Exec help commands from other buffer (was bug#36767: 26.1; request: add more quick keys to the *Help* buffer) Date: Mon, 27 Sep 2021 21:59:34 +0200 Message-ID: References: <87mtrrq7t7.fsf@gnus.org> <87eed0nsez.fsf@mail.linkov.net> <83bl83zp5h.fsf@gnu.org> <83y27nvnb4.fsf@gnu.org> <83ilyrvgda.fsf@gnu.org> <83h7ebv39d.fsf@gnu.org> <838rznusle.fsf@gnu.org> <87a6k2nlr6.fsf@mail.linkov.net> <83mto2rlyz.fsf@gnu.org> <83bl4hrxtu.fsf@gnu.org> 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="3363"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: martin rudalics , larsi@gnus.org, juri@linkov.net, Drew Adams , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 27 22:07:17 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mUwuB-0000dX-Qz for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 22:07:16 +0200 Original-Received: from localhost ([::1]:39662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUwuA-0006Ru-Tr for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 16:07:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUwms-00069h-Pm for emacs-devel@gnu.org; Mon, 27 Sep 2021 15:59:42 -0400 Original-Received: from mail-oln040092073069.outbound.protection.outlook.com ([40.92.73.69]:26142 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUwmq-0007vP-7o; Mon, 27 Sep 2021 15:59:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJi9sv/WxYXuxzlZywrRmNCsYmd1mTdhaUMDpxmNJyUYzzqjtgn9DJ7/nGBCysU7rat9+IbzxZyunN+hMriRezNLiyjzxbrfcosYV4idqVc7C8/xxmc/1zeW/uust5EQHq0Ot+NtZS6K8Yz96Y7FM5UyHPGRsovwi3FxNnZ83F34ZEMpm2s5GEgL0lBHaclXkBM+vmXWAxPP1NaKYPBQNOgih0D1xLxOik3Dmf4VB9Uj/fKlKihXxSRwBaP1xEC1JOG7vf8TUcX4VjDFODy3zjzfG1gTkNNwf4u3XhFTWkaFR7+OhoCSNCup8IWrkSJe/1xM0gIYZ4dRSJmBEYlllA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NewT29XYIALlR0ZZpfIgKJZPafLErgLbs4RVRWUqPgg=; b=XtbuekiHYWDmIRKlM0/98oJsd9ATghhfNHBPYtDSJd6Oa/XbswnE+xfwOMVH68+0Iyb4RWEZNYa9kINkZd8SHk9iKb76V8b82dYe+TZ4YTcYxGhRJ5tPJyvrxKmexeFyhT7vL0+9uWpF2EM2Qqt5PrljPHrX+LK42d6H8mHzFv1IxnMB6JYQCiZ+4L6t5eumXtmDNzO98AYXJodnb3A1ar/c0uYS4vz9gvzilbjCa0zDeOFYSCxNvDoNrB4PSXeaDnsoSInA/7VCrKufV405Z2+9Ose9HBc843mQ+Cl+vDG216VuYanQ4BtbGTYdSckDojHcou2P1R6mWfiTAsaPnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NewT29XYIALlR0ZZpfIgKJZPafLErgLbs4RVRWUqPgg=; b=DE5h/S0/tvCfvyhuRgXHkB5fZXy+cHtcmwqPwbdqoVz1UV+8o+8pJDQI8DCSeXdZ0w3uZxP1mX8292SqueeW3OBNiXbarRckwexdVGp7zIHQRM3EoAOdT2UKMXogxH64FiErflSb6IPI6Z2ebkB5Pn0LRvT0z71MHcEQ0BqrvnRrXuuDleFOjhSkKElwLkecfEnpkJ/KKA7SF2tn9JdSKoHJaWZhyV8P0UnNbt3BLmQhTz1dIlyDgHtogpz8EG6M3X3JEsdphJoSIjOB2qZMzgKDBgM8RiBvNe68piJ8QQA2+aRi1kXTwJ6XRW4EvqLpjFgwQ7cNJ9VNCuE8v+P83Q== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM9PR09MB4851.eurprd09.prod.outlook.com (2603:10a6:20b:2d4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Mon, 27 Sep 2021 19:59:36 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4544.022; Mon, 27 Sep 2021 19:59:36 +0000 In-Reply-To: (Arthur Miller's message of "Mon, 27 Sep 2021 13:07:51 +0200") X-TMN: [WOxCFN6fYcEnHPUcT/G7utX36Fvby4l+] X-ClientProxiedBy: HE1PR0501CA0029.eurprd05.prod.outlook.com (2603:10a6:3:1a::39) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87v92llrh5.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by HE1PR0501CA0029.eurprd05.prod.outlook.com (2603:10a6:3:1a::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Mon, 27 Sep 2021 19:59:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1bef531-d928-4b12-f4f5-08d981f15518 X-MS-TrafficTypeDiagnostic: AM9PR09MB4851: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Shs44QdYg6UbLdBV647RNX4gHMeCQzqPxNMweP8ZlT27wdvWpEwlVvCjJnceuHgtFndxAO2bXC32IXb31g4GdkWFfiQXl26MfzUcvWeCP0eiK7B20V93MVZMylFrNmMuHf37Ry6s4an4b4cCWm2DVcZgc3GrHKh33mQsKH1u9DFP5F8H7lvyq3y+9XofDQaMWeubMr3WBuMJBdOxLhKErSDuiC0mNkJrdEuRd123fMiPzkYeRmDI1YNTWeQ8+2IT9VSCA3PGuKqk0DQK34Dr7Mc4p4cLgpu4rqqwkaZScv6KnCUGS5vKu8d5+iWj5Ea9tLrelFrClFEHE/RfuKm8l78VYTqrqfQ7Hs6X033vShRL148NIAbUEsEj/fzZI5LUSQfmUYqQQgqIDbySCmMHEybJrllQEHHVf9jI+bdZ9B4ucaD1pCVeum5hxP0lj87y X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cq1lT6xv40ZO3aVsJUGMIZM97eBAb0+L5Cchu+PyvWx2EtDruHq2cPh/PBDkYpqCzdO/xnRs9ZXB6DkkMI8SgkEJkiR6e8gXCDFaP89ZgKAfXMyQCHSt5yiWjEi3Y/XWpuZjl6AkUEhmxgHH2W2o2w== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: f1bef531-d928-4b12-f4f5-08d981f15518 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 19:59:36.8538 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR09MB4851 Received-SPF: pass client-ip=40.92.73.69; envelope-from=arthur.miller@live.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275610 Archived-At: --=-=-= Content-Type: text/plain Arthur Miller writes: > Eli Zaretskii writes: > >>> From: Arthur Miller >>> Cc: Juri Linkov , larsi@gnus.org, emacs-devel@gnu.org >>> Date: Fri, 24 Sep 2021 21:57:13 +0200 >>> >>> > Please, no unnecessary generalizations of this kind. Or at least not >>> > to cater to this particular request. I want a _help_ command, not >>> > just a prefix that runs any command in the other window. because, for >>> > starters, what if the *Help* buffer is not currently on display at >>> > all? >>> >>> Here is one updated without the unnecessary let statement. >> >> Thanks, but I'd prefer a prefix command, so that you wouldn't need to >> prompt for the key sequence, but expect the user to provide it >> already. For example, "C-h M-h s" would show the definition of the >> function or variable. >> >> Also, the *Help* window should stay displayed, so any additional >> buffers the command needs to pop (for example, to show the definition) >> should not replace the *Help* buffer, it should pop in another window, >> exactly like when I invoke the command from the *Help* buffer. > > Ok, with iput from Martin, and wish to have this as a command prefix, after some > doc reading and test and trys, here is another patch. > > When help is not displayed, it silently does nothing, should some message be > emitted in minibuffer? This one goes to correct group and map :) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Run-help-mode-commands-form-any-buffer.patch >From 1841a5d32370e8fe0b493dcbe588b89b8051f12e Mon Sep 17 00:00:00 2001 From: Arthur Miller Date: Mon, 27 Sep 2021 21:55:42 +0200 Subject: [PATCH] Run help-mode commands form any buffer * help-mode.el (help-go-back): Addapted to call form any buufer. (help-window): New function. (with-help-buffer): New macro. (help-go-forward): Addapted to call form any buufer. (help-view-source): Addapted to call form any buufer. (help-goto-info): Addapted to call form any buufer. (help-command-prefix): New map. (help-command-prefix-key): New customize option. Install help-command-prefix map in global-map on C-h M-h key. --- lisp/help-mode.el | 100 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 24 deletions(-) diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 0b404fe89f..932af304a7 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -48,6 +48,23 @@ help-mode-map map) "Keymap for Help mode.") +(defvar help-command-prefix + (let ((map (define-prefix-command 'help-command-prefix))) + (define-key map "l" #'help-go-back) + (define-key map "r" #'help-go-forward) + (define-key map "\C-c\C-b" #'help-go-back) + (define-key map "\C-c\C-f" #'help-go-forward) + (define-key map [XF86Back] #'help-go-back) + (define-key map [XF86Forward] #'help-go-forward) + (define-key map "\C-c\C-c" #'help-follow-symbol) + (define-key map "s" #'help-view-source) + (define-key map "i" #'help-goto-info) + (define-key map "c" #'help-customize) + (fset 'help-command-prefix help-command-prefix) + (setq help-command-prefix help-command-prefix) + map) + "Keymap for Help command prefix.") + (easy-menu-define help-mode-menu help-mode-map "Menu for Help mode." '("Help-Mode" @@ -149,6 +166,20 @@ help-mode-hook "Hook run by `help-mode'." :type 'hook :group 'help) + +(defcustom help-command-prefix-key "C-h M-h" + "The key HELP-COMMAND-PREFIX is bound to in the global map." + :type '(choice (string :tag "Key") (const :tag "no binding")) + :set (lambda (var key) + (when (and (boundp var) (symbol-value var)) + (define-key (current-global-map) + (read-kbd-macro (symbol-value var)) nil)) + (when key + (define-key (current-global-map) + (read-kbd-macro key) 'help-command-prefix)) + (set var key)) + :group 'help + :version "28.1") ;; Button types used by help @@ -402,7 +433,8 @@ help-mode-finish "Finalize Help mode setup in current buffer." (when (derived-mode-p 'help-mode) (setq buffer-read-only t) - (help-make-xrefs (current-buffer)))) + (help-make-xrefs (current-buffer)) + (set-window-dedicated-p (get-buffer-window (help-buffer)) t))) ;; Grokking cross-reference information in doc strings and ;; hyperlinking it. @@ -741,6 +773,21 @@ 'help-xref-interned ;; Navigation/hyperlinking with xrefs +(defun help-window () + "Return help-buffer window or nil help-buffer is not currently displayed." + (when (get-buffer "*Help*") + (get-buffer-window (get-buffer "*Help*")))) + +(defmacro with-help-buffer (&rest body) + "Execute the forms in BODY with HELP-BUFFER temporarily current. + +BODY will be executed onlu if HELP-BUFFER is displayed in a live +window on the screen." + (declare (indent 1) (debug t)) + `(when (help-window) + (with-current-buffer (help-buffer) + ,@body))) + (defun help-xref-go-back (buffer) "From BUFFER, go back to previous help buffer text using `help-xref-stack'." (let (item position method args) @@ -784,44 +831,49 @@ help-xref-go-forward (defun help-go-back () "Go back to previous topic in this help buffer." (interactive) - (if help-xref-stack - (help-xref-go-back (current-buffer)) - (user-error "No previous help buffer"))) + (with-help-buffer + (if help-xref-stack + (help-xref-go-back (current-buffer)) + (user-error "No previous help buffer")))) (defun help-go-forward () "Go to the next topic in this help buffer." (interactive) - (if help-xref-forward-stack - (help-xref-go-forward (current-buffer)) - (user-error "No next help buffer"))) + (with-help-buffer + (if help-xref-forward-stack + (help-xref-go-forward (current-buffer)) + (user-error "No next help buffer")))) (defun help-view-source () "View the source of the current help item." (interactive nil help-mode) - (unless (plist-get help-mode--current-data :file) - (error "Source file for the current help item is not defined")) - (help-function-def--button-function - (plist-get help-mode--current-data :symbol) - (plist-get help-mode--current-data :file) - (plist-get help-mode--current-data :type))) + (with-help-buffer + (unless (plist-get help-mode--current-data :file) + (error "Source file for the current help item is not defined")) + (help-function-def--button-function + (plist-get help-mode--current-data :symbol) + (plist-get help-mode--current-data :file) + (plist-get help-mode--current-data :type)))) (defun help-goto-info () "View the *info* node of the current help item." (interactive nil help-mode) - (unless help-mode--current-data - (error "No symbol to look up in the current buffer")) - (info-lookup-symbol (plist-get help-mode--current-data :symbol) - 'emacs-lisp-mode)) + (with-help-buffer + (unless help-mode--current-data + (error "No symbol to look up in the current buffer")) + (info-lookup-symbol (plist-get help-mode--current-data :symbol) + 'emacs-lisp-mode))) (defun help-customize () "Customize variable or face whose doc string is shown in the current buffer." (interactive nil help-mode) - (let ((sym (plist-get help-mode--current-data :symbol))) - (unless (or (boundp sym) (facep sym)) - (user-error "No variable or face to customize")) - (cond - ((boundp sym) (customize-variable sym)) - ((facep sym) (customize-face sym))))) + (with-help-buffer + (let ((sym (plist-get help-mode--current-data :symbol))) + (unless (or (boundp sym) (facep sym)) + (user-error "No variable or face to customize")) + (cond + ((boundp sym) (customize-variable sym)) + ((facep sym) (customize-face sym)))))) (defun help-do-xref (_pos function args) "Call the help cross-reference function FUNCTION with args ARGS. @@ -844,7 +896,7 @@ help-follow-mouse (defun help-follow () "Follow cross-reference at point. -For the cross-reference format, see `help-make-xrefs'." +For the cross-reference format, see `help-make-xrsefs'." (declare (obsolete nil "28.1")) (interactive) (user-error "No cross-reference here")) -- 2.33.0 --=-=-=--