From 2b812b1c9f91af2cf6116f1d4e334154ae44c724 Mon Sep 17 00:00:00 2001 From: Nicolas Richard Date: Thu, 8 Oct 2015 10:50:07 +0200 Subject: [PATCH] Allow M-x man to reuse an existing window * man.el (Man-notify-when-ready): add `manly' option. (Man-notify-method): augment docstring accordingly. --- lisp/man.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/man.el b/lisp/man.el index c5dbcba..a02ee79 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -91,6 +91,8 @@ (require 'ansi-color) (require 'cl-lib) (require 'button) +(require 'subr-x) +(require 'seq) (defgroup man nil "Browse UNIX manual pages." @@ -162,6 +164,8 @@ (defcustom Man-notify-method (if (boundp 'Man-notify) Man-notify 'friendly) 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) +manly -- like `friendly' but re-use a window displaying a man page if + possible (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 @@ -1166,6 +1170,16 @@ (defun Man-notify-when-ready (man-buffer) (and (frame-live-p saved-frame) (select-frame saved-frame)) (display-buffer man-buffer 'not-this-window)) + (`manly + (and (frame-live-p saved-frame) + (select-frame saved-frame)) + (if-let ((window (seq-some-p + (lambda (window) + (with-current-buffer (window-buffer window) + (derived-mode-p 'Man-mode))) + (window-list)))) + (set-window-buffer window man-buffer) + (display-buffer man-buffer))) (`polite (beep) (message "Manual buffer %s is ready" (buffer-name man-buffer))) -- 2.4.6