From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.bugs Subject: bug#21649: 25.0.50; [PATCH] Allow M-x man to reuse an existing window Date: Thu, 08 Oct 2015 17:54:02 +0200 Message-ID: <877fmxz78l.fsf@members.fsf.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1444319921 24057 80.91.229.3 (8 Oct 2015 15:58:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2015 15:58:41 +0000 (UTC) To: 21649@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 08 17:58:30 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from eggs.gnu.org ([208.118.235.92]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZkDaO-0006Pq-Dp for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 17:58:28 +0200 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDZp-0007pX-P7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 11:58:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDZp-0007p8-Ma for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 11:57:53 -0400 Original-Received: from localhost ([::1]:35714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDZp-0002m5-KP for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 11:57:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDZ6-0002k8-Ec for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:57:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDY2-00060S-CH for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:57:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDY2-0005ym-32 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZkDY1-0001Ks-T4 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nicolas Richard Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 15:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14443197395097 (code B ref -1); Thu, 08 Oct 2015 15:56:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Oct 2015 15:55:39 +0000 Original-Received: from localhost ([127.0.0.1]:32817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDXf-0001K8-D0 for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:55:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59110) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZkDXc-0001Jz-C5 for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:55:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDXG-0004WN-Vx for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:55:35 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:55325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDXG-0004WF-Sq for submit@debbugs.gnu.org; Thu, 08 Oct 2015 11:55:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDWX-00027V-KS for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:55:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkDVT-00081b-I4 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:54:29 -0400 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:48909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkDVS-0007pK-JX for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 11:53:22 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai4IAMyQFlakD4Xx/2dsb2JhbABeglWCFKhnAQEBAQEBBgWQLoYKgxOCCn8CghYBAQEBAQGBC4QmAQKBFRQDAQIKNAEEOyGILp8XpD2GLIpBHhGEFwWNCYkBlhuSd2OEBDwzh2wBAQE Original-Received: from mathsrv4.ulb.ac.be (HELO localhost) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 08 Oct 2015 17:53:21 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 Xref: news.gmane.org gmane.emacs.bugs:107447 Archived-At: --=-=-= Content-Type: text/plain When running M-x man RET man RET, then C-x o to select the newly created window and then running M-x man RET sed RET, what you get is: two "man" windows side by side. It would make sense to re-use the existing one. How to best do that I do not know. If modifying the code is necessary, here's an attempt at adding an option in Man-notify-method. (I'm not attached to this implementation, and even less attached to the silly name `manly' that I chose, btw.) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Allow-M-x-man-to-reuse-an-existing-window.patch >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 --=-=-=--