Skip to content

Commit

Permalink
ol-man: Set window point not buffer point and wait before search
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tgbugs authored and yantar92 committed Aug 10, 2022
1 parent be7f611 commit 7664325
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lisp/ol-man.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ 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)
(let ((process (get-buffer-process buffer)))
(while (process-live-p process)
(accept-process-output process)))
(goto-char (point-min))
(search-forward search))
(forward-line -1)
(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."
Expand Down

0 comments on commit 7664325

Please sign in to comment.