3

Instead of open many buffers I wish to have the same buffer for all calls to the man.

Francesco Cadei
  • 327
  • 3
  • 17

1 Answers1

3

Here's a function following @Drew's excellent suggestion:

(defun last-man-standing ()
  (interactive)
  (kill-matching-buffers "^\*Man .*\*" nil t)
  (call-interactively #'man))

A couple of notes:

  1. I used call-interactively to preserve man's fancy guessing of which man page you want.

  2. I didn't know that kill-matching-buffers existed, but since Emacs often has exactly the function you need I went C-h f kill-match TAB and sure enough, it was there.

Omar
  • 4,732
  • 1
  • 17
  • 32