Here's a patch to fix the follow behavior for ol-man links so
that the ::SEARCH functionality will actually work. Best!
Tom
From 2c3e3b994fd7b47a6e91d147d2b1f08cd97a1908 Mon Sep 17 00:00:00 2001
From: Tom Gillespie <[email protected]>
Date: Thu, 28 Jul 2022 23:33:22 -0700
Subject: [PATCH] * lisp/ol-man.el (org-man-open): Set window point not buffer
point
When passed man:path::SEARCH org-man-open tries to use search-forward
to jump to the location of e.g. a heading. Prior to this fix it only
used search-forward, which will not change the point of the cursor in
the window, meaning that even if there is a match it will not appear.
Use sleep-for as a horrible hack to work around the fact that the man
command runs in the background with no way to synchronize back.
---
lisp/ol-man.el | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index aa22964c5..5843cd5f6 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -43,12 +43,20 @@ If PATH contains extra ::STRING which will use `occur' to search
matched strings in man buffer."
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
(let* ((command (match-string 1 path))
- (search (match-string 2 path)))
- (funcall org-man-command command)
+ (search (match-string 2 path))
+ (buffer (funcall org-man-command command)))
(when search
- (with-current-buffer (concat "*Man " command "*")
- (goto-char (point-min))
- (search-forward search)))))
+ (with-current-buffer buffer
+ (goto-char (point-min))
+ (unless (search-forward search nil t)
+ (sleep-for 0.75) ; async, can't block, no callback
+ (goto-char (point-min))
+ (search-forward search))
+ (previous-line)
+ (let ((point (point)))
+ (let ((window (get-buffer-window buffer)))
+ (set-window-point window point)
+ (set-window-start window point)))))))
(defun org-man-store-link ()
"Store a link to a README file."
--
2.35.1