From: martin rudalics <rudalics@gmx.at>
To: Nicolas Richard <youngfrog@members.fsf.org>
Cc: "21649@debbugs.gnu.org" <21649@debbugs.gnu.org>
Subject: bug#21649: 25.0.50; [PATCH] Allow M-x man to reuse an existing window
Date: Tue, 01 Mar 2016 18:04:08 +0100 [thread overview]
Message-ID: <56D5CB88.7000900@gmx.at> (raw)
In-Reply-To: <861t7unqq4.fsf@members.fsf.org>
> Well, it took a bit of time but here I am ! Could you please review the
> following patch ?
Thanks for the patch!
+(defun display-buffer-reuse-mode-window (buffer alist)
+ "Return a window based on the mode of the buffer it displays.
+Display BUFFER in the returned window. Return nil if no usable
^
+window is found.
+
+If ALIST contains a `mode' entry, its value is a major mode (a
+symbol) or a list of modes. A window is a candidate if it
+displays a buffer that derives from one of the given modes. When
^
+ALIST contains no `mode' entry, the current major mode of BUFFER
+is used.
Please consistently use two spaces after each sentence in doc-strings,
comments etc.
+ (dolist (window windows)
+ (let ((window-mode (with-current-buffer
+ (window-buffer window)
+ major-mode))
+ mode? frame?)
+ (setq mode?
+ (cond ((memq window-mode allowed-modes)
+ 'same)
+ ((let ((major-mode window-mode))
+ (derived-mode-p allowed-modes))
+ 'derived)))
It's not nice to bind a buffer-local variable like ‘major-mode’ in a
completely unrelated buffer just for calling ‘derived-mode-p’. Please
do that either within the ‘with-current-buffer’ form above, somehow like
(dolist (window windows)
(let (window-mode window-derived-mode mode? frame?)
(with-current-buffer (window-buffer window)
(setq window-mode major-mode)
(setq window-derived-mode (derived-mode-p allowed-modes)))
(setq mode?
(cond ((memq window-mode allowed-modes)
'same)
(window-derived-mode
'derived)))
or simply write
((with-current-buffer (window-buffer window))
(derived-mode-p allowed-modes))
'derived)))
instead.
+ (let ((window (first (nconc same-mode-same-frame
This gets me
In end of data:
window.el:8617:1:Warning: the function ‘first’ is not known to be defined.
here.
Thanks again, martin
next prev parent reply other threads:[~2016-03-01 17:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 15:54 bug#21649: 25.0.50; [PATCH] Allow M-x man to reuse an existing window Nicolas Richard
2015-10-09 14:37 ` Kaushal Modi
[not found] ` <86r3l09t3u.fsf@members.fsf.org>
2015-10-12 15:06 ` Kaushal Modi
2015-10-13 22:10 ` Nicolas Richard
2015-10-13 22:19 ` Kaushal Modi
2015-10-14 8:49 ` martin rudalics
[not found] ` <86wpufc8n8.fsf@members.fsf.org>
2015-10-22 15:34 ` martin rudalics
2015-10-22 19:21 ` Nicolas Richard
2015-10-23 8:01 ` martin rudalics
2016-03-01 15:49 ` Nicolas Richard
2016-03-01 17:04 ` martin rudalics [this message]
2016-03-10 9:55 ` Nicolas Richard
2016-03-10 10:32 ` martin rudalics
2016-03-10 13:49 ` Nicolas Richard
2015-10-27 11:30 ` Nicolas Richard
2015-10-28 9:55 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56D5CB88.7000900@gmx.at \
--to=rudalics@gmx.at \
--cc=21649@debbugs.gnu.org \
--cc=youngfrog@members.fsf.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.