From: Eduardo Ochs <eduardoochs@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How do I make `man' run some code after the manpage is fully rendered?
Date: Sat, 2 Jan 2021 06:04:37 -0300 [thread overview]
Message-ID: <CADs++6i18WYSy5+tDyb869UPZLK_raihL4MQd=qaRZ4d5fvkdA@mail.gmail.com> (raw)
In-Reply-To: <jwveej99lvr.fsf-monnier+emacs@gnu.org>
Perfect, thanks!!!
The code below - with (advice-add 'Man-bgproc-sentinel ...) - works in
at least Emacs25.2, Emacs26, and Emacs27 - I got a segfault trying to
compile Emacs25.1 here.
The code is just 32 lines long, so I thought that it would be worth
sharing it with the list.
Cheers! =)
Eduardo Ochs
http://angg.twu.net/#eev
Here it goes:
(defvar ee-find-man-flag nil "See `find-man'.")
(defvar ee-find-man-buffer nil "See `find-man'.")
(defvar ee-find-man-pos-spec-list nil "See `find-man'.")
(defun find-man (manpage &rest pos-spec-list)
"Hyperlink to a manpage."
(interactive (list (ee-manpagename-ask)))
(setq manpage (Man-translate-references manpage))
;;
;; Set the variables used by `ee-find-man-goto-pos-spec'.
(setq ee-find-man-flag t)
(setq ee-find-man-buffer (concat "*Man " manpage "*"))
(setq ee-find-man-pos-spec-list pos-spec-list)
;;
;; See: (find-evardescr 'Man-notify-method "pushy" "current window")
(let ((Man-notify-method 'pushy))
;;
;; This call to `man' will run `ee-find-man-goto-pos-spec' after
;; the manpage is rendered - because of the `advice-add' below.
;; This is a dirty trick!... see:
;; https://lists.gnu.org/archive/html/help-gnu-emacs/2020-12/msg01100.html
;; https://lists.gnu.org/archive/html/help-gnu-emacs/2020-12/msg01102.html
(man manpage)))
(defun ee-find-man-goto-pos-spec (&rest rest)
"An internal function used by `find-man'."
(when ee-find-man-flag
(setq ee-find-man-flag nil)
(with-current-buffer ee-find-man-buffer
(apply 'ee-goto-position ee-find-man-pos-spec-list))))
(advice-add 'Man-bgproc-sentinel :after 'ee-find-man-goto-pos-spec)
On Tue, 29 Dec 2020 at 03:19, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> If you need to adjust the content of the page, then you can try using
> the `Man-cooked-hook`. But if you need to move to a particular position
> that won't help because man moves to page 1 after running this hook.
> I think withthe current man.el code you'll need an advice on
> `Man-bgproc-sentinel`.
>
> Stefan
prev parent reply other threads:[~2021-01-02 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 4:55 How do I make `man' run some code after the manpage is fully rendered? Eduardo Ochs
2020-12-29 6:19 ` Stefan Monnier
2021-01-02 9:04 ` Eduardo Ochs [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADs++6i18WYSy5+tDyb869UPZLK_raihL4MQd=qaRZ4d5fvkdA@mail.gmail.com' \
--to=eduardoochs@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.