4

When I open a man page (e.g. M-x man cat) I would like to automatically move my cursor onto the man page. I already know how to achieve this behavior for *Help* and *Apropos*, and I want to get the same behavior for Man mode too. I have tried this:

(add-hook 'Man-mode-hook
          (lambda ()
            (pop-to-buffer (current-buffer))))

This works when opening a man page for the first time. However, when opening the same man page a second time, the Man window will be shown, but the cursor will not be moved to it. For example, if I do M-x man cat for the first time, the man page for "cat" will be shown and the cursor will be moved to it. However, if I delete the man page window (C-x 0) and ask for the same man page again (M-x man cat), the man page for "cat" will be shown, but the cursor will not be moved to it.

How do I automatically select the Man mode buffer when it is shown?

0
4

See the variable Man-notify-method, which can be customized. Specifically, the O.P. may be interested in the value 'aggressive. The following is a printout of the *Help* buffer for C-h v aka M-x describe-variable:

Man-notify-method is a variable defined in ‘man.el’.
Its value is ‘friendly’

  You can customize this variable.
  Probably introduced at or before Emacs version 19.29.

Documentation:
Selects the behavior when manpage is ready.
This variable may have one of the following values, where (sf) means
that the frames are switched, so the manpage is displayed in the frame
where the man command was called from:

newframe   -- put the manpage in its own frame (see ‘Man-frame-parameters’)
pushy      -- make the manpage the current buffer in the current window
bully      -- make the manpage the current buffer and only window (sf)
aggressive -- make the manpage the current buffer in the other window (sf)
friendly   -- display manpage in the other window but don’t make current (sf)
polite     -- don’t display manpage, but prints message and beep when ready
quiet      -- like ‘polite’, but don’t beep
meek       -- make no indication that the manpage is ready

Any other value of ‘Man-notify-method’ is equivalent to ‘meek’.
1
  • 1
    Thank you. Adding (setq Man-notify-method 'aggressive) to ~/.emacs solved the problem.
    – Flux
    Feb 3 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.