> You should rather let-bind org-man-command to a helper function that
> will setup the mock buffer and return it. That will avoid relying on
> what `man' command does.
Thanks for the guidance! I've updated the test patch to a better regression
test.
Sent with Proton Mail secure email.
On Saturday, November 8th, 2025 at 3:53 AM, Ihor Radchenko
<[email protected]> wrote:
> Catsup4 [email protected] writes:
>
> > Sorry if this has been intentionally disabled due to the bug mentioned in
> > the FIXME comment. I tried tracing back that thread and I couldn't tell if
> > disabling the string searching was intentional or an unintended side effect
>
>
> Unintended side effect. Thanks for the fix!
>
> > From 825a26e20e1da0904d26f881d9cd445e3974cad1 Mon Sep 17 00:00:00 2001
> > From: Catsup4 [email protected]
> > Date: Fri, 7 Nov 2025 20:20:16 -0800
> > Subject: [PATCH 1/2] lisp/ol-man.el: restore `::STRING' searching
>
>
> Applied, onto bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=eb8c1fff8
>
> > I included this test as a separate commit because it demonstrates the
> > bug bug behavior and the fix, but perhaps it shouldn't be merged as it
> > is a brittle test. The testing emacs testing docs mention that you
> > shouldn't modify customizations, but in this test I set the
> > `org-man-command' to` man'
>
>
> let-binding is ok, but the test is relying upon the behavior of man
> command and, more specifically, on how it constructs and searches buffers.
>
> > +(ert-deftest test-org-man-open ()
> > + (org-man-open-fixture
> > + (lambda ()
> > + (let ((org-man-command 'man)
>
>
> You should rather let-bind org-man-command to a helper function that
> will setup the mock buffer and return it. That will avoid relying on
> what `man' command does.
>
> --
> Ihor Radchenko // yantar92,
> Org mode maintainer,
> Learn more about Org mode at https://orgmode.org/.
>
> Support Org development at https://liberapay.com/org-mode,
>
> or support my work at https://liberapay.com/yantar92
From 76bfe26b6da9a895b4c54d7816aa6c03175338aa Mon Sep 17 00:00:00 2001
From: Catsup4 <[email protected]>
Date: Fri, 7 Nov 2025 20:59:42 -0800
Subject: [PATCH] test-ol-man.el: add a test of `::STRING' searching
* testing/lisp/test-ol-man.el: Add an initial test file for man page
links
This is a test to cover the bugfix in eb8c1fff8
TINYCHANGE
---
testing/lisp/test-ol-man.el | 73 +++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 testing/lisp/test-ol-man.el
diff --git a/testing/lisp/test-ol-man.el b/testing/lisp/test-ol-man.el
new file mode 100644
index 000000000..fc1e6a8c1
--- /dev/null
+++ b/testing/lisp/test-ol-man.el
@@ -0,0 +1,73 @@
+;;; test-ol-man.el --- tests for ol-man.el -*- lexical-binding: t; -*-
+
+;; Author: <[email protected]>
+;; Keywords: outlines, hypermedia, text
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Links to man pages rely on a regexp that uses capture groups to
+;; extract the man command and a search string to be run within the
+;; given man page. These tests exersise that logic.
+
+;;; Code:
+(require 'ol-man)
+
+(defun test-ol-man--man-command (_)
+ "This function sets up a buffer named \"*Man 1 fake*\".
+It then fills it with some test content. This will be used as a mock man
+command for testing `org-man-open'."
+ (let ((man-buffer-name "*Man 1 fake*")
+ (man-buffer-text "(1)\t\tGNU\t\t fake (1)
+line 2 of this fake man page
+line 3 of fake man page for the command fake(1)
+"))
+ (with-current-buffer (get-buffer-create man-buffer-name)
+ (insert man-buffer-text)
+ (goto-char 0))
+ (get-buffer man-buffer-name)))
+
+(defun org-man-open-fixture (body &rest search)
+ "This function sets up a mock man page buffer using `test-ol-man--man-command'.
+If SEARCH is provided, the man command will have it added as the
+`::STRING' search portion of the `org-man-open' command. The mock man
+page buffer is killed after the test BODY is run."
+
+ (let* ((man-buffer-command "fake(1)")
+ (man-buffer-name "*Man 1 fake*")
+ (org-man-command 'test-ol-man--man-command)
+ (org-link (if (car search) (concat man-buffer-command "::" (car search)) man-buffer-command)))
+ (unwind-protect
+ (progn
+ ;; the second argument is unused in org-man-open
+ (org-man-open org-link nil)
+ (with-current-buffer man-buffer-name
+ (funcall body)))
+ (kill-buffer man-buffer-name))))
+
+(ert-deftest test-org-man-open-no-search ()
+ (org-man-open-fixture (lambda () (should (equal 1 (point))))))
+
+(ert-deftest test-org-man-open-with-found-search ()
+ (org-man-open-fixture (lambda () (should (equal 21 (point)))) "Line 3"))
+
+(ert-deftest test-org-man-open-with-unfound-search ()
+ (should-error
+ (org-man-open-fixture (lambda () ) "not in the man page")))
+
+
+(provide 'test-ol-man)
+
+;;; test-ol-man.el ends here
--
2.48.1