From: martin rudalics <rudalics@gmx.at>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: 16793@debbugs.gnu.org
Subject: bug#16793: window-state-put needs a live window
Date: Tue, 18 Feb 2014 20:04:28 +0100 [thread overview]
Message-ID: <5303AEBC.6020509@gmx.at> (raw)
In-Reply-To: <CAAeL0SSUzP2HJ891pO1UOQGV_gQqGh68cb9xyu_pCG-FqKH1qA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 484 bytes --]
> But I still think that getting a window-state for a window and putting
> it again into the same window should always be allowed, unless Martin
> has a good reason why that symmetry is a bad idea.
I tend to agree with you. But the obvious consequence is that the
WINDOW argument of `window-state-put' could then specify an internal
window that is not the root window of its frame. In this case plain
`delete-other-windows' would be the wrong action. I attach a patch.
martin
[-- Attachment #2: window-state-put.diff --]
[-- Type: text/plain, Size: 1393 bytes --]
=== modified file 'lisp/window.el'
--- lisp/window.el 2014-02-10 01:34:22 +0000
+++ lisp/window.el 2014-02-18 18:59:17 +0000
@@ -5026,14 +5026,29 @@
"Put window state STATE into WINDOW.
STATE should be the state of a window returned by an earlier
invocation of `window-state-get'. Optional argument WINDOW must
-specify a live window and defaults to the selected one.
+specify a valid window and defaults to the selected one. If
+WINDOW is not live, delete all child windows of WINDOW before
+putting STATE.
Optional argument IGNORE non-nil means ignore minimum window
sizes and fixed size restrictions. IGNORE equal `safe' means
windows can get as small as `window-safe-min-height' and
`window-safe-min-width'."
(setq window-state-put-stale-windows nil)
- (setq window (window-normalize-window window t))
+ (setq window (window-normalize-window window))
+
+ (unless (window-live-p window)
+ (let ((root (frame-root-window)))
+ (if (eq window root)
+ (setq window (frame-first-window root))
+ (setq root window)
+ (setq window (catch 'live
+ (walk-window-subtree
+ (lambda (window)
+ (when (window-live-p window)))
+ root))))
+ (delete-other-windows-internal window root)))
+
(let* ((frame (window-frame window))
(head (car state))
;; We check here (1) whether the total sizes of root window of
next prev parent reply other threads:[~2014-02-18 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-18 16:20 bug#16793: window-state-put needs a live window Juanma Barranquero
2014-02-18 17:09 ` Stefan Monnier
2014-02-18 17:20 ` Glenn Morris
2014-02-18 17:24 ` Glenn Morris
2014-02-18 18:28 ` Stefan Monnier
2014-02-18 18:37 ` Glenn Morris
2014-02-18 20:45 ` Stefan Monnier
2014-02-18 17:36 ` Juanma Barranquero
2014-02-18 18:29 ` Stefan Monnier
2014-02-18 19:04 ` martin rudalics [this message]
2014-02-18 21:18 ` Juanma Barranquero
2014-02-18 21:26 ` martin rudalics
2014-02-18 21:51 ` Juanma Barranquero
2014-02-19 10:02 ` martin rudalics
2014-02-19 11:09 ` Juanma Barranquero
2014-02-18 19:04 ` martin rudalics
2014-02-18 19:08 ` Juanma Barranquero
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5303AEBC.6020509@gmx.at \
--to=rudalics@gmx.at \
--cc=16793@debbugs.gnu.org \
--cc=lekktu@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).