From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#36588: Unable to revert M-x apropos help buffer Date: Thu, 11 Jul 2019 15:53:56 +0100 Message-ID: <87h87sk4fv.fsf@tcd.ie> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="100008"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36588@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 11 16:55:27 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlaTm-000PpI-Bz for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jul 2019 16:55:26 +0200 Original-Received: from localhost ([::1]:42432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlaTl-0008SE-Cn for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jul 2019 10:55:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41944) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlaTQ-00085w-Mj for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 10:55:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlaTP-0000SK-2a for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 10:55:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlaTO-0000Rk-LH for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 10:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hlaTO-0007KP-FL for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 10:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jul 2019 14:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36588 X-GNU-PR-Package: emacs Original-Received: via spool by 36588-submit@debbugs.gnu.org id=B36588.156285684728076 (code B ref 36588); Thu, 11 Jul 2019 14:55:02 +0000 Original-Received: (at 36588) by debbugs.gnu.org; 11 Jul 2019 14:54:07 +0000 Original-Received: from localhost ([127.0.0.1]:38368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlaSV-0007Ik-9h for submit@debbugs.gnu.org; Thu, 11 Jul 2019 10:54:07 -0400 Original-Received: from mail-wr1-f65.google.com ([209.85.221.65]:46614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlaST-0007IA-0Q for 36588@debbugs.gnu.org; Thu, 11 Jul 2019 10:54:05 -0400 Original-Received: by mail-wr1-f65.google.com with SMTP id z1so6605828wru.13 for <36588@debbugs.gnu.org>; Thu, 11 Jul 2019 07:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ThmJjBssfJ8Bg08h9Hg5v/qhvf2slyQbf/9GF8qaE0M=; b=G3jSldDcHJWZE1jk3Nw4Fm1HYo9qBU2DzE39Qbio3WtIVnZjN7Qj32SHT+jatVd2lK Rqzl9gFyurPE6Vh/8DAhFsV5/aQUY/OF6XyIhQYscZoi64ISLnhhhJhQ9LKr8fjgJshf 1+jG/fmqdoqgbguCByEmevpXhQDE9wmBgQ8fzz9m6ZFLb9crvFed+cyLQEGqB/K7P18T f6+2Q5bz/JM+XSSDS9WcGM6GneQO57PkSv+xHw0Rv0I6p/Lvd5rF8iGb4LNHVElbg+sl 2GQnllBTMYK/E+hql5WvQ/RdxB70hrGcegDzpRvHbqSoriIn11S36D4fngyRPOQ4PA3E wdRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ThmJjBssfJ8Bg08h9Hg5v/qhvf2slyQbf/9GF8qaE0M=; b=B6KH5nVSXmDz1Nv/0EppCMPAY+grQcLo7TyX77oLQfnfqeor3va0nBh6jkeVf2+ER7 wzydmo/K0dQ149kdI14WmXtSe0QP4kTNSwN6RogsVSCIa9a6oQzttgMTMNvBdemCupYq dlt0qNx3OYN+Y3Dai4ql1dMFOwKYQWkVjAibOK9YuMF1yRJC5rz5itJwBwOVsYFF416y TpsqM3cdPH4v5qj8pa+IkR4M8t6zYgG+qtSrQssZl4MCyAMXrJOSLV5iOHfoCec6RkeJ xza0sKJmJ2ME2ZUBADyhjPCjgRmbI2BfqwhowthT1OqVds8bKvNZUXv8PBzgQRxxIxkf DAlA== X-Gm-Message-State: APjAAAVa44FKgyLuf3nTsAa3gDW51v/9J81XM1nh1nLOMHop0EIvmmQC 5nNEkvGtMe8s96gz4QT/OC8KdAPyNY4= X-Google-Smtp-Source: APXvYqzHkgUrtRO4BHKW0U1qyeA2+90zek2Bq5Ba2i+/YLd1fjR4Tw37iVOHNbBzIwgKT2poJYx/WA== X-Received: by 2002:a5d:5692:: with SMTP id f18mr5697791wrv.104.1562856838652; Thu, 11 Jul 2019 07:53:58 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id j189sm6283001wmb.48.2019.07.11.07.53.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 07:53:57 -0700 (PDT) In-Reply-To: (Stefan Kangas's message of "Thu, 11 Jul 2019 05:31:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162708 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable severity 36588 minor tags 36588 + patch quit Stefan Kangas writes: > I get an error trying to revert the apropos help buffer on Emacs 27 > (current master). I could also reproduce this on 26.1. > > Steps to reproduce: > 0. emacs -Q > 1. M-x apropos RET foo RET > 2. C-x o > 3. g yes RET > 4. Error: > apply: Symbol=E2=80=99s function definition is void: nil > > Backtrace: > Debugger entered--Lisp error: (void-function nil) > nil() > apply(nil nil) > help-mode-revert-buffer(t nil) > revert-buffer(t) > funcall-interactively(revert-buffer t) > #(revert-buffer nil nil) > apply(# revert-buffer (nil nil)) > call-interactively@ido-cr+-record-current-command(# call-interactively> revert-buffer nil nil) > apply(call-interactively@ido-cr+-record-current-command # call-interactively> (revert-buffer nil nil)) > call-interactively(revert-buffer nil nil) > command-execute(revert-buffer) This is because Apropos buffers are set up in apropos-print using with-output-to-temp-buffer, which by default calls help-mode, which sets revert-buffer-function permanently-locally to help-mode-revert-buffer. [Aside: Why is revert-buffer-function permanent-local?] help-mode-revert-buffer expects the command which generated the Help buffer to have previously called help-setup-xref. This should be possible to do in Apropos, but it would be quite ugly as help-setup-xref needs to be called with the Help buffer current, so Apropos commands would need to set their own version of help-xref-stack-item before apropos-print performs the help-setup-xref dance. Besides, Apropos buffers are not (currently) really Help buffers. Instead, I propose emulating a simpler version of help-setup-xref specific to Apropos: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Support-reverting-Apropos-buffers-bug-36588.patch >From 890d2d6c1447f207892be734ab7412b4b471ddb7 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Thu, 11 Jul 2019 15:11:35 +0100 Subject: [PATCH] Support reverting Apropos buffers (bug#36588) * lisp/apropos.el (apropos--current): New variable akin to help-xref-stack-item storing information for revert-buffer. (apropos--revert-buffer): New function. (apropos-mode): Use it as revert-buffer-function. (apropos-command, apropos, apropos-library, apropos-value) (apropos-local-value, apropos-documentation): Set apropos--current in low-level commands, i.e., those which do not call other commands. --- lisp/apropos.el | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lisp/apropos.el b/lisp/apropos.el index 1b86f5bcde..79e5a1518f 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -212,6 +212,12 @@ apropos-synonyms Each element is a list of words where the first word is the standard Emacs term, and the rest of the words are alternative terms.") +(defvar apropos--current nil + "List of current Apropos function followed by its arguments. +Used by `apropos--revert-buffer' to regenerate the current +Apropos buffer. Each Apropos command should ensure it is set +before `apropos-mode' makes it buffer-local.") + ;;; Button types used by apropos @@ -472,10 +478,18 @@ apropos-true-hit-doc "Return t if DOC is really matched by the current keywords." (apropos-true-hit doc apropos-all-words)) +(defun apropos--revert-buffer (_ignore-auto noconfirm) + "Regenerate current Apropos buffer using `apropos--current'. +Intended as a value for `revert-buffer-function'." + (when (or noconfirm (yes-or-no-p "Revert apropos buffer? ")) + (apply #'funcall apropos--current))) + (define-derived-mode apropos-mode special-mode "Apropos" "Major mode for following hyperlinks in output of apropos commands. -\\{apropos-mode-map}") +\\{apropos-mode-map}" + (make-local-variable 'apropos--current) + (setq-local revert-buffer-function #'apropos--revert-buffer)) (defvar apropos-multi-type t "If non-nil, this apropos query concerns multiple types. @@ -550,6 +564,7 @@ apropos-command (if (or current-prefix-arg apropos-do-all) "command or function" "command")) current-prefix-arg)) + (setq apropos--current (list #'apropos-command pattern do-all var-predicate)) (apropos-parse-pattern pattern) (let ((message (let ((standard-output (get-buffer-create "*Apropos*"))) @@ -628,6 +643,7 @@ apropos Returns list of symbols and documentation found." (interactive (list (apropos-read-pattern "symbol") current-prefix-arg)) + (setq apropos--current (list #'apropos pattern do-all)) (apropos-parse-pattern pattern) (apropos-symbols-internal (apropos-internal apropos-regexp @@ -670,6 +686,7 @@ apropos-library libs)) libs))) (list (completing-read "Describe library: " libs nil t)))) + (setq apropos--current (list #'apropos-library file)) (let ((symbols nil) ;; (autoloads nil) (provides nil) @@ -776,6 +793,7 @@ apropos-value Returns list of symbols and values found." (interactive (list (apropos-read-pattern "value") current-prefix-arg)) + (setq apropos--current (list #'apropos-value pattern do-all)) (apropos-parse-pattern pattern) (or do-all (setq do-all apropos-do-all)) (setq apropos-accumulator ()) @@ -815,6 +833,7 @@ apropos-local-value Optional arg BUFFER (default: current buffer) is the buffer to check." (interactive (list (apropos-read-pattern "value of buffer-local variable"))) (unless buffer (setq buffer (current-buffer))) + (setq apropos--current (list #'apropos-local-value pattern buffer)) (apropos-parse-pattern pattern) (setq apropos-accumulator ()) (let ((var nil)) @@ -856,6 +875,7 @@ apropos-documentation ;; output, but I cannot see that that is true. (interactive (list (apropos-read-pattern "documentation") current-prefix-arg)) + (setq apropos--current (list #'apropos-documentation pattern do-all)) (apropos-parse-pattern pattern) (or do-all (setq do-all apropos-do-all)) (setq apropos-accumulator () apropos-files-scanned ()) -- 2.20.1 --=-=-= Content-Type: text/plain I don't consider this duplication because, unless Apropos were completely refactored, setting something like apropos--current would be necessary either way. This has the added perk of not coupling Apropos with Help any more than it currently needs to be. WDYT? Thanks, -- Basil --=-=-=--