all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* decode_any_window
@ 2008-12-07 13:02 martin rudalics
  0 siblings, 0 replies; only message in thread
From: martin rudalics @ 2008-12-07 13:02 UTC (permalink / raw)
  To: emacs-devel

With Emacs 23 `fit-window-to-buffer' contains the following code:

(defun fit-window-to-buffer (&optional window max-height min-height)
    ...
       (unless (zerop delta)
	(enlarge-window delta))
       ...
		    (= desired-height (window-height window))

When delta is negative, `enlarge-window' will shrink WINDOW and, if this
makes its height less than that of `window-min-height', delete it.  OTOH
`window-height' operates on ANY window regardless of whether it's live
or has been deleted.  Now if WINDOW is a full-height child of a parent
window which is not the root window of that frame, deleting that parent
window calls the routine delete_all_subwindows which, as a special hack,
temporarily stores the name of the buffer displayed by WINDOW in the
number of lines of the window.  As a consequence, (window-height window)
returns the buffer previously shown in WINDOW and the test for equality
fails because a buffer is neither a number nor a marker.  Emacs 22
worked around this problem by temporarily binding `window-min-height' to
1, so WINDOW didn't get deleted.

Hence in this special case an apparently reasonable operation fails
gracefully for a reason hardly anyone will understand.  I'm not sure
whether other operations fail equally gracefully.  The Elisp manual
warns:

      *Warning:* Erroneous information or fatal errors may result from
      using a deleted window as if it were live.

But this advice is problematic because quite often we can't say what
"using" stands for.  Do we "use" a deleted window when we call
`window-height' on it?

The problem is that decode_window considers a window "live" when it has
a buffer.  Parent windows don't have a buffer but we want to execute
`window-height' on them, so we use decode_any_window.  I suppose TRT for
decode_any_window is to check whether it has either a buffer or a
vertical or horizontal child.  But maybe we want to decode effectively
"dead" windows too for some reason?

martin





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-07 13:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-07 13:02 decode_any_window martin rudalics

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.