From: Tom Gillespie <tgbugs@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ol-man.el (org-man-open): Set window point not buffer point
Date: Tue, 9 Aug 2022 17:41:58 -0700 [thread overview]
Message-ID: <CA+G3_PPvD6yaJ941imiAO8EYXjw33oDpUNWx0K_W7RNyp0D6+w@mail.gmail.com> (raw)
In-Reply-To: <87lerx4ntc.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
> (while (process-live-p process)
> (accept-process-output process)))
When I tried this before it didn't work, but now it does, I
must have missed something. Patch updated accordingly.
The order in which the man.el code does things is supremely
confusing, but I think when accept-process-output returns that
means the process sentinel has finished its final run and the
man buffer is fully populated so it is safe to search.
> Also, compiling the patch yields
No byte compiler errors now, and I think I got all the formatting issues.
[-- Attachment #2: 0001-ol-man-Set-window-point-not-buffer-point-and-wait-be.patch --]
[-- Type: text/x-patch, Size: 2104 bytes --]
From 848d6fc9bd395d7d45f14af71c4df8ea44ed7b4c Mon Sep 17 00:00:00 2001
From: Tom Gillespie <tgbugs@gmail.com>
Date: Thu, 28 Jul 2022 23:33:22 -0700
Subject: [PATCH] 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.
---
lisp/ol-man.el | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index aa22964c5..24e896f30 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -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."
--
2.35.1
next prev parent reply other threads:[~2022-08-10 0:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 6:47 [PATCH] ol-man.el (org-man-open): Set window point not buffer point Tom Gillespie
2022-07-29 13:20 ` Ihor Radchenko
2022-08-09 1:39 ` Tom Gillespie
2022-08-09 12:13 ` Ihor Radchenko
2022-08-10 0:41 ` Tom Gillespie [this message]
2022-08-10 11:47 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+G3_PPvD6yaJ941imiAO8EYXjw33oDpUNWx0K_W7RNyp0D6+w@mail.gmail.com \
--to=tgbugs@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).