6

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

1 Answer 1

6

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. Commented Feb 3, 2021 at 17:06

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.