Skip to content

Commit 7664325

Browse files
tgbugsyantar92
authored andcommitted
ol-man: Set window point not buffer point and wait before search
* lisp/ol-man.el (org-man-open): Set window point not buffer point and wait before search. When passed man:path::SEARCH `org-man-open' uses `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 `accept-process-output' to block until the manpage finishes rendering before searching the buffer so that there will be something to find.
1 parent be7f611 commit 7664325

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lisp/ol-man.el

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,22 @@ If PATH contains extra ::STRING which will use `occur' to search
4343
matched strings in man buffer."
4444
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
4545
(let* ((command (match-string 1 path))
46-
(search (match-string 2 path)))
47-
(funcall org-man-command command)
46+
(search (match-string 2 path))
47+
(buffer (funcall org-man-command command)))
4848
(when search
49-
(with-current-buffer (concat "*Man " command "*")
50-
(goto-char (point-min))
51-
(search-forward search)))))
49+
(with-current-buffer buffer
50+
(goto-char (point-min))
51+
(unless (search-forward search nil t)
52+
(let ((process (get-buffer-process buffer)))
53+
(while (process-live-p process)
54+
(accept-process-output process)))
55+
(goto-char (point-min))
56+
(search-forward search))
57+
(forward-line -1)
58+
(let ((point (point)))
59+
(let ((window (get-buffer-window buffer)))
60+
(set-window-point window point)
61+
(set-window-start window point)))))))
5262

5363
(defun org-man-store-link ()
5464
"Store a link to a README file."

0 commit comments

Comments
 (0)