unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: 73686@debbugs.gnu.org
Cc: emacs-erc@gnu.org
Subject: bug#73686: 31.0.50; ERC 5.6.1-git: back button gone from describe-face via erc-nicks-list-faces
Date: Tue, 08 Oct 2024 17:59:54 -0700	[thread overview]
Message-ID: <8734l6xf91.fsf__13820.799141989$1728435707$gmane$org@neverwas.me> (raw)
In-Reply-To: <87o73uyxgv.fsf@neverwas.me> (J. P.'s message of "Tue, 08 Oct 2024 16:41:04 -0700")

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Actually, we can't count on `help-buffer-under-preparation' being
non-nil in `describe-*' commands (unless we're willing to modify all the
ones in which it isn't, which sounds rather dubious). Patch updated.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0000-v1-v2.diff --]
[-- Type: text/x-patch, Size: 2361 bytes --]

From 0e19883da585b0105f2340ac7c23764b3ea939c9 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Tue, 8 Oct 2024 17:33:11 -0700
Subject: [PATCH 0/1] *** NOT A PATCH ***

*** BLURB HERE ***

F. Jason Park (1):
  [POC] Overload help-xref-following for non-default help buffers

 lisp/help-mode.el                     | 21 +++++++++++++--------
 test/lisp/emacs-lisp/package-tests.el |  2 +-
 test/lisp/help-mode-tests.el          | 14 +++++++++++++-
 3 files changed, 27 insertions(+), 10 deletions(-)

Interdiff:
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index f704098b2dc..77473125694 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -524,16 +524,14 @@ help-buffer
   "Return the name of a buffer for inserting help.
 If `help-xref-following' is t and the current buffer is derived from
 `help-mode', return the current buffer's name.  As a special case, also
-do so if these three conditions are met: `help-xref-following' is the
-symbol of a major mode deriving from `help-mode', the current buffer is
-in `fundamental-mode', and `help-buffer-under-preparation' is non-nil.
+do so if `help-xref-following' is the symbol of a major mode deriving
+from `help-mode' and the current buffer is in `fundamental-mode'.
 Otherwise, return \"*Help*\", creating a buffer with that name if
 it does not already exist."
   (buffer-name                         ;for with-output-to-temp-buffer
    (if (and help-xref-following
             (if (or (eq help-xref-following t)
-                    (not (and help-buffer-under-preparation
-                              (eq major-mode 'fundamental-mode))))
+                    (not (eq major-mode 'fundamental-mode)))
                 (derived-mode-p 'help-mode) ; current buffer
               (provided-mode-derived-p help-xref-following '(help-mode))))
        (current-buffer)
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 692d6550250..8236f834b02 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -172,7 +172,7 @@ with-fake-help-buffer
   `(with-temp-buffer
     (help-mode)
     ;; Trick `help-buffer' into using the temp buffer.
-    (let ((help-xref-following t))
+    (let ((help-xref-following major-mode))
       ,@body)))
 
 (defun package-test-strip-version (dir)
-- 
2.46.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-POC-Overload-help-xref-following-for-non-default-hel.patch --]
[-- Type: text/x-patch, Size: 5486 bytes --]

From 0e19883da585b0105f2340ac7c23764b3ea939c9 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Tue, 8 Oct 2024 15:58:49 -0700
Subject: [PATCH 1/1] [POC] Overload help-xref-following for non-default help
 buffers

* lisp/help-mode.el (help-xref-following): Mention in doc that value may
be the symbol of a major mode.
(help-buffer): When the current buffer is in `fundamental-mode', check
to see if the value of `help-xref-following' is the symbol of a major
mode deriving from `help-mode' before returning the current buffer.
This should also probably check whether `help-buffer-under-preparation'
is non-nil, but many `describe-*' functions do not bind it.
(help-xref-go-back, help-xref-go-forward): Use `help-do-xref' instead of
`apply' to call methods.
(help-do-xref): Bind `help-xref-following' to the value of `major-mode'
instead of t.
* test/lisp/emacs-lisp/package-tests.el (with-fake-help-buffer): Use
value of `major-mode' instead of t for `help-xref-following'.
* test/lisp/help-mode-tests.el
(help-mode-tests-help-buffer-current-buffer): Add case for
`help-xref-following' being a major-mode rather than t.  (Bug#73686)
(See also: bug#73637.)
---
 lisp/help-mode.el                     | 21 +++++++++++++--------
 test/lisp/emacs-lisp/package-tests.el |  2 +-
 test/lisp/help-mode-tests.el          | 14 +++++++++++++-
 3 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 4ee4f4156a1..77473125694 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -516,19 +516,24 @@ help-setup-xref
     (setq help-xref-stack-item item)))
 
 (defvar help-xref-following nil
-  "Non-nil when following a help cross-reference.")
+  "Non-nil when following a help cross-reference.
+May be the value of `major-mode' when an instigating button was clicked.")
 
 ;;;###autoload
 (defun help-buffer ()
   "Return the name of a buffer for inserting help.
-If `help-xref-following' is non-nil and the current buffer is
-derived from `help-mode', this is the name of the current buffer.
-
+If `help-xref-following' is t and the current buffer is derived from
+`help-mode', return the current buffer's name.  As a special case, also
+do so if `help-xref-following' is the symbol of a major mode deriving
+from `help-mode' and the current buffer is in `fundamental-mode'.
 Otherwise, return \"*Help*\", creating a buffer with that name if
 it does not already exist."
   (buffer-name                         ;for with-output-to-temp-buffer
    (if (and help-xref-following
-            (derived-mode-p 'help-mode))
+            (if (or (eq help-xref-following t)
+                    (not (eq major-mode 'fundamental-mode)))
+                (derived-mode-p 'help-mode) ; current buffer
+              (provided-mode-derived-p help-xref-following '(help-mode))))
        (current-buffer)
      (get-buffer-create "*Help*"))))
 
@@ -792,7 +797,7 @@ help-xref-go-back
 	      position (car item)
 	      method (cadr item)
 	      args (cddr item))))
-    (apply method args)
+    (help-do-xref nil method args)
     (with-current-buffer buffer
       (if (get-buffer-window buffer)
 	  (set-window-point (get-buffer-window buffer) position)
@@ -812,7 +817,7 @@ help-xref-go-forward
 	      position (car item)
 	      method (cadr item)
 	      args (cddr item))))
-    (apply method args)
+    (help-do-xref nil method args)
     (with-current-buffer buffer
       (if (get-buffer-window buffer)
 	  (set-window-point (get-buffer-window buffer) position)
@@ -894,7 +899,7 @@ help-do-xref
 Things are set up properly so that the resulting help buffer has
 a proper [back] button."
   ;; There is a reference at point.  Follow it.
-  (let ((help-xref-following t))
+  (let ((help-xref-following major-mode))
     (apply function (if (eq function 'info)
                         (append args (list (generate-new-buffer-name "*info*")))
                       args))))
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 692d6550250..8236f834b02 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -172,7 +172,7 @@ with-fake-help-buffer
   `(with-temp-buffer
     (help-mode)
     ;; Trick `help-buffer' into using the temp buffer.
-    (let ((help-xref-following t))
+    (let ((help-xref-following major-mode))
       ,@body)))
 
 (defun package-test-strip-version (dir)
diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el
index 2e64b12732e..968ed7da72e 100644
--- a/test/lisp/help-mode-tests.el
+++ b/test/lisp/help-mode-tests.el
@@ -39,7 +39,19 @@ help-mode-tests-help-buffer-current-buffer
     (help-mode)
     (let ((help-xref-following t))
       (should (equal (buffer-name (current-buffer))
-                     (help-buffer))))))
+                     (help-buffer)))))
+
+  ;; Returns the current `fundamental-mode' buffer when an xref button
+  ;; is clicked and the resulting action function, such as the various
+  ;; `describe-*' commands, binds `help-buffer-under-preparation' to
+  ;; something non-nil.
+  (should (eq major-mode 'fundamental-mode))
+  (let ((help-xref-following 'help-mode)
+        (help-buffer-under-preparation t))
+    (should (equal (buffer-name (current-buffer))
+                   (help-buffer)))
+    (with-current-buffer "*scratch*"
+      (should (equal "*Help*" (help-buffer))))))
 
 (ert-deftest help-mode-tests-make-xrefs ()
   (with-temp-buffer
-- 
2.46.2


  parent reply	other threads:[~2024-10-09  0:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  2:47 bug#73686: 31.0.50; ERC 5.6.1-git: back button gone from describe-face via erc-nicks-list-faces J.P.
2024-10-08  6:06 ` J.P.
     [not found] ` <87ttdn5dsz.fsf@neverwas.me>
2024-10-08 21:07   ` J.P.
     [not found]   ` <87y12y1exp.fsf@neverwas.me>
2024-10-08 23:41     ` J.P.
     [not found]     ` <87o73uyxgv.fsf@neverwas.me>
2024-10-09  0:59       ` J.P. [this message]
     [not found]       ` <8734l6xf91.fsf@neverwas.me>
2024-10-09  3:00         ` J.P.
2024-10-09  1:05   ` Dmitry Gutov
2024-10-09  1:24     ` J.P.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='8734l6xf91.fsf__13820.799141989$1728435707$gmane$org@neverwas.me' \
    --to=jp@neverwas.me \
    --cc=73686@debbugs.gnu.org \
    --cc=emacs-erc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).