Subject: [bug#65376] [PATCH emacs-team 3/7] gnu: emacs-helpful: Update to 0.21.

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 19 Aug 2023 01:05:22 +0200

* gnu/packages/patches/emacs-helpful-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs-xyz.scm (emacs-helpful): Update to 0.21.
[source]<patches>: Use it here.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/emacs-xyz.scm                    | 51 +++++++++----------
 .../patches/emacs-helpful-fix-tests.patch     | 28 ++++++++++
 3 files changed, 54 insertions(+), 26 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-helpful-fix-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e14a9adc33..3b087a6d5e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1097,6 +1097,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-fix-scheme-indent-function.patch	\
   %D%/packages/patches/emacs-json-reformat-fix-tests.patch	\
   %D%/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch	\
+  %D%/packages/patches/emacs-helpful-fix-tests.patch	\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch   \
   %D%/packages/patches/emacs-native-comp-driver-options.patch   \
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 1e03625f62..dbc176e379 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -24363,31 +24363,30 @@ (define-public emacs-download-region
       (license license:gpl3+))))
 
 (define-public emacs-helpful
-  (let ((commit "1c98f6f06a85def5d34c735f8cd407f20cebddf9")
-        (revision "1"))
-    (package
-      (name "emacs-helpful")
-      (version (git-version "0.19" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/Wilfred/helpful")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32 "18b5hjfji51zxjrxhkklxx3j9svk295awmxv8n95mp8ilas2kd3l"))))
-      (build-system emacs-build-system)
-      (propagated-inputs
-       (list emacs-dash emacs-elisp-refs emacs-f emacs-s))
-      (native-inputs
-       (list emacs-ert-runner emacs-undercover))
-      (arguments
-       `(#:tests? #t
-         #:test-command '("ert-runner")))
-      (home-page "https://github.com/Wilfred/helpful")
-      (synopsis "More contextual information in Emacs help")
-      (description "@code{helpful} is an alternative to the built-in Emacs help
+  (package
+    (name "emacs-helpful")
+    (version "0.21")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Wilfred/helpful")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "03afgdbs5nmhw833svrqky7fmfs1zlvqzcj7j5g29sakivs60xqc"))
+       (patches (search-patches "emacs-helpful-fix-tests.patch"))))
+    (build-system emacs-build-system)
+    (propagated-inputs
+     (list emacs-dash emacs-elisp-refs emacs-f emacs-s))
+    (native-inputs
+     (list emacs-ert-runner emacs-undercover))
+    (arguments
+     `(#:tests? #t
+       #:test-command '("ert-runner")))
+    (home-page "https://github.com/Wilfred/helpful")
+    (synopsis "More contextual information in Emacs help")
+    (description "@code{helpful} is an alternative to the built-in Emacs help
 that provides much more contextual information.
 
 @itemize
@@ -24406,7 +24405,7 @@ (define-public emacs-helpful
 @item Trace, disassemble functions from inside Helpful.  This is discoverable
 and doesn't require memorisation of commands.
 @end itemize\n")
-      (license license:gpl3+))))
+    (license license:gpl3+)))
 
 (define-public emacs-logview
   (package
diff --git a/gnu/packages/patches/emacs-helpful-fix-tests.patch b/gnu/packages/patches/emacs-helpful-fix-tests.patch
new file mode 100644
index 0000000000..61ed0671a4
--- /dev/null
+++ b/gnu/packages/patches/emacs-helpful-fix-tests.patch
@@ -0,0 +1,28 @@
+From 233e254bbe44f70ca899a506b3706af489228fda Mon Sep 17 00:00:00 2001
+From: aagon <[email-masked]>
+Date: Thu, 10 Aug 2023 20:03:52 +0200
+Subject: [PATCH] Repair helpful--display-implementations test for emacs 29.1
+
+---
+ test/helpful-unit-test.el | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
+index 0f5177b..0716b0d 100644
+--- a/test/helpful-unit-test.el
++++ b/test/helpful-unit-test.el
+@@ -1089,8 +1089,12 @@ find the source code."
+   (require 'xref)
+   (helpful-function 'xref-location-marker)
+   (should (s-contains-p "Implementations" (buffer-string)))
+-  (should (s-contains-p "((l xref-file-location))" (buffer-string)))
+-  (should (s-contains-p "((l xref-buffer-location))" (buffer-string))))
++  (should (if (version< emacs-version "29.1")
++	      (s-contains-p "((l xref-file-location))" (buffer-string))
++	    (s-contains-p "(xref-location-marker (L xref-file-location))" (buffer-string))))
++  (should (if (version< emacs-version "29.1")
++	      (s-contains-p "((l xref-buffer-location))" (buffer-string))
++	    (s-contains-p "(xref-location-marker (L xref-buffer-location))" (buffer-string)))))
+ 
+ (defun helpful--boring-advice (orig-fn &rest args)
+   (apply orig-fn args))
-- 
2.41.0