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
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
* ol-man.el (org-man-open): The optional `::STRING' portion of man
page links was not being used. This change restores that
functionality.
The issue is that the capture groups from the `string-match' call are
being reset before `search' is saved to a variable, resulting in
search always being nil.
TINYCHANGE
---
lisp/ol-man.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index 2511d8166..fc504149a 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -51,7 +51,8 @@ If PATH contains extra ::STRING which will use `occur' to search
matched strings in man buffer."
(require 'man) ; For `Man-translate-references'
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
- (let* ((command (match-string 1 path))
+ (let* ((search (match-string 2 path))
+ (command (match-string 1 path))
;; FIXME: Remove after we drop Emacs 29 support.
;; Working around security bug #66390.
(command (if (not (equal (Man-translate-references ";id") ";id"))
@@ -64,7 +65,6 @@ matched strings in man buffer."
(mapcar #'shell-quote-argument
(split-string command "\\s-+"))
" ")))
- (search (match-string 2 path))
(buffer (funcall org-man-command command)))
(when search
(with-current-buffer buffer
--
2.48.1
From 1a164826cbf7ef417e037fe214cc2f91e4078896 Mon Sep 17 00:00:00 2001
From: Catsup4 <[email protected]>
Date: Fri, 7 Nov 2025 20:59:42 -0800
Subject: [PATCH 2/2] testing/lisp/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
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'
I do not have any experience with emacs-lisp testing and I am pretty
sure someone more familiar with elisp and erc could do this in a much
cleaner way.
TINYCHANGE
---
testing/lisp/test-ol-man.el | 54 +++++++++++++++++++++++++++++++++++++
1 file changed, 54 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..6d9d34df6
--- /dev/null
+++ b/testing/lisp/test-ol-man.el
@@ -0,0 +1,54 @@
+;;; 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 org-man-open-fixture (body)
+ "This function sets up a buffer named \"*Man 1 emacs*\".
+It then fills it with some test content. This will be used as the man
+page buffer in the test `BODY'."
+
+ (unwind-protect
+ (progn
+ (let ((mock-man-buffer (get-buffer-create "*Man 1 emacs*" nil))
+ (mock-man-contents (concat "EMACS(1)\t\tGNU\t\tEMACS(1)\n"
+ "NAME\n"
+ "emacs - GNU project Emacs editor\n")))
+ (with-current-buffer mock-man-buffer
+ (insert mock-man-contents)
+ (goto-char 0))
+ (funcall body))
+ (kill-buffer "*Man 1 emacs*"))))
+
+(ert-deftest test-org-man-open ()
+ (org-man-open-fixture
+ (lambda ()
+ (let ((org-man-command 'man)
+ (expected-position-in-man-buffer 25))
+ (should (equal expected-position-in-man-buffer (org-man-open "emacs(1)::emacs - GNU project Emacs editor" nil)))))))
+
+(provide 'test-ol-man)
+
+;;; test-ol-man.el ends here
--
2.48.1