summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog40
-rw-r--r--lisp/mail/rmail.el2
-rw-r--r--lisp/window.el170
3 files changed, 133 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6352a65e4fc..6cc9cc86515 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,43 @@
+2011-11-06 Chong Yidong <cyd@gnu.org>
+
+ * window.el (window-combination-p): Function deleted; its
+ side-effect is not used in any existing code.
+ (window-combinations, window-combined-p): Call window-*-child
+ directly.
+
+2011-11-05 Chong Yidong <cyd@gnu.org>
+
+ * window.el (window-valid-p): Rename from window-any-p.
+ (window-size-ignore, window-state-get): Callers changed.
+ (window-normalize-window): Rename from window-normalize-any-window.
+ New arg LIVE-ONLY, replacing window-normalize-live-window.
+ (window-normalize-live-window): Deleted.
+ (window-combination-p, window-combined-p, window-combinations)
+ (walk-window-subtree, window-atom-root, window-min-size)
+ (window-sizable, window-sizable-p, window-size-fixed-p)
+ (window-min-delta, window-max-delta, window-resizable)
+ (window-resizable-p, window-full-height-p, window-full-width-p)
+ (window-current-scroll-bars, window-point-1, set-window-point-1)
+ (window-at-side-p, window-in-direction, window-resize)
+ (adjust-window-trailing-edge, maximize-window, minimize-window)
+ (window-deletable-p, delete-window, delete-other-windows)
+ (record-window-buffer, unrecord-window-buffer)
+ (switch-to-prev-buffer, switch-to-next-buffer, window--delete)
+ (quit-window, split-window, window-state-put)
+ (set-window-text-height, fit-window-to-buffer)
+ (shrink-window-if-larger-than-buffer): Callers changed.
+
+2011-11-04 Eli Zaretskii <eliz@gnu.org>
+
+ * mail/rmail.el (rmail-simplified-subject): Decode subject with
+ rfc2047-decode-string.
+ (rmail-mime-toggle-hidden): Declare to avoid byte-compilation
+ warnings.
+
+ * window.el (window-body-height, window-body-width): Mention in
+ the doc string that the return values are in frame's canonical
+ units. (Bug#9949)
+
2011-11-03 Alan Mackenzie <acm@muc.de>
* progmodes/cc-langs.el (c-nonlabel-token-2-key): New variable for
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 603a615192a..a535d3a86db 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -194,6 +194,7 @@ please report it with \\[report-emacs-bug].")
(declare-function mail-dont-reply-to "mail-utils" (destinations))
(declare-function rmail-update-summary "rmailsum" (&rest ignore))
+(declare-function rmail-mime-toggle-hidden "rmailmm" ())
(defun rmail-probe (prog)
"Determine what flavor of movemail PROG is.
@@ -3262,6 +3263,7 @@ Interactively, empty argument means use same regexp used last time."
Simplifying the subject means stripping leading and trailing whitespace,
and typical reply prefixes such as Re:."
(let ((subject (or (rmail-get-header "Subject" msgnum) "")))
+ (setq subject (rfc2047-decode-string subject))
(if (string-match "\\`[ \t]+" subject)
(setq subject (substring subject (match-end 0))))
(if (string-match rmail-reply-regexp subject)
diff --git a/lisp/window.el b/lisp/window.el
index 9b12c204d48..1b51bde36bd 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -100,8 +100,10 @@ be any window."
(setq window (window-next-sibling window))))
window)
-(defsubst window-any-p (object)
- "Return t if OBJECT denotes a live or internal window."
+(defsubst window-valid-p (object)
+ "Return t if OBJECT denotes a live window or internal window.
+Otherwise, return nil; this includes the case where OBJECT is a
+deleted window."
(and (windowp object)
(or (window-buffer object) (window-child object))
t))
@@ -130,24 +132,21 @@ FRAME must be a live frame and defaults to the selected frame."
(error "%s is not a live frame" frame))
(selected-frame)))
-(defsubst window-normalize-any-window (window)
+(defsubst window-normalize-window (window &optional live-only)
"Return window specified by WINDOW.
-WINDOW must be a window that has not been deleted and defaults to
-the selected window."
- (if window
- (if (window-any-p window)
- window
- (error "%s is not a window" window))
- (selected-window)))
-
-(defsubst window-normalize-live-window (window)
- "Return live window specified by WINDOW.
-WINDOW must be a live window and defaults to the selected one."
- (if window
- (if (and (windowp window) (window-buffer window))
- window
- (error "%s is not a live window" window))
- (selected-window)))
+If WINDOW is nil, return `selected-window'.
+If WINDOW is a live window or internal window, return WINDOW;
+ if LIVE-ONLY is non-nil, return WINDOW for a live window only.
+Otherwise, signal an error."
+ (cond ((null window)
+ (selected-window))
+ (live-only
+ (if (window-live-p window)
+ window
+ (error "%s is not a live window" window)))
+ ((if (window-valid-p window)
+ window
+ (error "%s is not a window" window)))))
(defvar ignore-window-parameters nil
"If non-nil, standard functions ignore window parameters.
@@ -196,36 +195,35 @@ narrower, explictly specify the SIZE argument of that function."
:version "24.1"
:group 'windows)
-(defun window-combination-p (&optional window horizontal)
- "If WINDOW is a vertical combination return WINDOW's first child.
-WINDOW can be any window and defaults to the selected one.
-Optional argument HORIZONTAL non-nil means return WINDOW's first
-child if WINDOW is a horizontal combination."
- (setq window (window-normalize-any-window window))
- (if horizontal
- (window-left-child window)
- (window-top-child window)))
-
(defsubst window-combined-p (&optional window horizontal)
- "Return non-nil if and only if WINDOW is vertically combined.
-WINDOW can be any window and defaults to the selected one.
-Optional argument HORIZONTAL non-nil means return non-nil if and
-only if WINDOW is horizontally combined."
- (setq window (window-normalize-any-window window))
+ "Return non-nil if WINDOW has siblings in a given direction.
+If WINDOW is omitted or nil, it defaults to the selected window.
+
+HORIZONTAL determines a direction for the window combination.
+If HORIZONTAL is omitted or nil, return non-nil if WINDOW is part
+of a vertical window combination.
+If HORIZONTAL is non-nil, return non-nil if WINDOW is part of a
+horizontal window combination."
+ (setq window (window-normalize-window window))
(let ((parent (window-parent window)))
- (and parent (window-combination-p parent horizontal))))
+ (and parent
+ (if horizontal
+ (window-left-child parent)
+ (window-top-child parent)))))
(defun window-combinations (&optional window horizontal)
"Return largest number of vertically arranged subwindows of WINDOW.
-WINDOW can be any window and defaults to the selected one.
-Optional argument HORIZONTAL non-nil means to return the largest
-number of horizontally arranged subwindows of WINDOW."
- (setq window (window-normalize-any-window window))
+If WINDOW is omitted or nil, it defaults to the selected window.
+If HORIZONTAL is non-nil, return the largest number of
+horizontally arranged subwindows of WINDOW."
+ (setq window (window-normalize-window window))
(cond
((window-live-p window)
;; If WINDOW is live, return 1.
1)
- ((window-combination-p window horizontal)
+ ((if horizontal
+ (window-left-child window)
+ (window-top-child window))
;; If WINDOW is iso-combined, return the sum of the values for all
;; subwindows of WINDOW.
(let ((child (window-child window))
@@ -289,7 +287,7 @@ on all live and internal subwindows of WINDOW.
This function performs a pre-order, depth-first traversal of the
window tree rooted at WINDOW. If PROC changes that window tree,
the result is unpredictable."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(walk-window-tree-1 proc window any t))
(defun windows-with-parameter (parameter &optional value frame any values)
@@ -335,7 +333,7 @@ too."
"Return root of atomic window WINDOW is a part of.
WINDOW can be any window and defaults to the selected one.
Return nil if WINDOW is not part of a atomic window."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let (root)
(while (and window (window-parameter window 'window-atom))
(setq root window)
@@ -532,7 +530,7 @@ window).")
(defsubst window-size-ignore (window ignore)
"Return non-nil if IGNORE says to ignore size restrictions for WINDOW."
- (if (window-any-p ignore) (eq window ignore) ignore))
+ (if (window-valid-p ignore) (eq window ignore) ignore))
(defun window-min-size (&optional window horizontal ignore)
"Return the minimum number of lines of WINDOW.
@@ -547,7 +545,7 @@ windows may get as small as `window-safe-min-height' lines and
`window-safe-min-width' columns. IGNORE a window means ignore
restrictions for that window only."
(window-min-size-1
- (window-normalize-any-window window) horizontal ignore))
+ (window-normalize-window window) horizontal ignore))
(defun window-min-size-1 (window horizontal ignore)
"Internal function of `window-min-size'."
@@ -640,7 +638,7 @@ imposed by fixed size windows, `window-min-height' or
windows may get as small as `window-safe-min-height' lines and
`window-safe-min-width' columns. IGNORE any window means ignore
restrictions for that window only."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(cond
((< delta 0)
(max (- (window-min-size window horizontal ignore)
@@ -658,7 +656,7 @@ restrictions for that window only."
"Return t if WINDOW can be resized by DELTA lines.
For the meaning of the arguments of this function see the
doc-string of `window-sizable'."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(if (> delta 0)
(>= (window-sizable window delta horizontal ignore) delta)
(<= (window-sizable window delta horizontal ignore) delta)))
@@ -706,7 +704,7 @@ If this function returns nil, this does not necessarily mean that
WINDOW can be resized in the desired direction. The functions
`window-resizable' and `window-resizable-p' will tell that."
(window-size-fixed-1
- (window-normalize-any-window window) horizontal))
+ (window-normalize-window window) horizontal))
(defun window-min-delta-1 (window delta &optional horizontal ignore trail noup)
"Internal function for `window-min-delta'."
@@ -772,7 +770,7 @@ tree but try to enlarge windows within WINDOW's combination only.
Optional argument NODOWN non-nil means don't check whether WINDOW
itself \(and its subwindows) can be shrunk; check only whether at
least one other windows can be enlarged appropriately."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let ((size (window-total-size window horizontal))
(minimum (window-min-size window horizontal ignore)))
(cond
@@ -854,7 +852,7 @@ WINDOW's combination.
Optional argument NODOWN non-nil means do not check whether
WINDOW itself \(and its subwindows) can be enlarged; check only
whether other windows can be shrunk appropriately."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(if (and (not (window-size-ignore window ignore))
(not nodown) (window-size-fixed-p window horizontal))
;; With IGNORE and NOWDON nil return zero if WINDOW has fixed
@@ -898,7 +896,7 @@ within WINDOW's combination.
Optional argument NODOWN non-nil means don't check whether WINDOW
and its subwindows can be resized."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(cond
((< delta 0)
(max (- (window-min-delta window horizontal ignore trail noup nodown))
@@ -912,7 +910,7 @@ and its subwindows can be resized."
"Return t if WINDOW can be resized vertically by DELTA lines.
For the meaning of the arguments of this function see the
doc-string of `window-resizable'."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(if (> delta 0)
(>= (window-resizable window delta horizontal ignore trail noup nodown)
delta)
@@ -941,7 +939,7 @@ More precisely, return t if and only if the total height of
WINDOW equals the total height of the root window of WINDOW's
frame. WINDOW can be any window and defaults to the selected
one."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(= (window-total-size window)
(window-total-size (frame-root-window window))))
@@ -960,7 +958,7 @@ otherwise."
More precisely, return t if and only if the total width of WINDOW
equals the total width of the root window of WINDOW's frame.
WINDOW can be any window and defaults to the selected one."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(= (window-total-size window t)
(window-total-size (frame-root-window window) t)))
@@ -972,7 +970,14 @@ The return value does not include WINDOW's mode line and header
line, if any. If a line at the bottom of the window is only
partially visible, that line is included in the return value. If
you do not want to include a partially visible bottom line in the
-return value, use `window-text-height' instead."
+return value, use `window-text-height' instead.
+
+Note that the return value is measured in canonical units, i.e. for
+the default frame's face. If the window shows some characters with
+non-default face, e.g., if the font of some characters is larger or
+smaller than the default font, the value returned by this function
+will not match the actual number of lines shown in the window. To
+get the actual number of lines, use `posn-at-point'."
(window-body-size window))
(defsubst window-body-width (&optional window)
@@ -982,7 +987,14 @@ WINDOW must be a live window and defaults to the selected one.
The return value does not include any vertical dividers or scroll
bars owned by WINDOW. On a window-system the return value does
not include the number of columns used for WINDOW's fringes or
-display margins either."
+display margins either.
+
+Note that the return value is measured in canonical units, i.e. for
+the default frame's face. If the window shows some characters with
+non-default face, e.g., if the font of some characters is larger or
+smaller than the default font, the value returned by this function
+will not match the actual number of characters per line shown in the
+window. To get the actual number of columns, use `posn-at-point'."
(window-body-size window t))
;; Eventually we should make `window-height' obsolete.
@@ -1001,7 +1013,7 @@ or nil).
Unlike `window-scroll-bars', this function reports the scroll bar
type actually used, once frame defaults and `scroll-bar-mode' are
taken into account."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(let ((vert (nth 2 (window-scroll-bars window)))
(hor nil))
(when (or (eq vert t) (eq hor t))
@@ -1065,7 +1077,7 @@ WINDOW can be any live window and defaults to the selected one.
This function is like `window-point' with one exception: If
WINDOW is selected, it returns the value of `point' of WINDOW's
buffer regardless of whether that buffer is current or not."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(if (eq window (selected-window))
(with-current-buffer (window-buffer window)
(point))
@@ -1078,7 +1090,7 @@ WINDOW can be any live window and defaults to the selected one.
This function is like `set-window-point' with one exception: If
WINDOW is selected, it moves `point' of WINDOW's buffer to POS
regardless of whether that buffer is current or not."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(if (eq window (selected-window))
(with-current-buffer (window-buffer window)
(goto-char pos))
@@ -1089,7 +1101,7 @@ regardless of whether that buffer is current or not."
WINDOW can be any window and defaults to the selected one. SIDE
can be any of the symbols `left', `top', `right' or `bottom'.
The default value nil is handled like `bottom'."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let ((edge
(cond
((eq side 'left) 0)
@@ -1131,7 +1143,7 @@ DIRECTION must be one of `above', `below', `left' or `right'.
WINDOW must be a live window and defaults to the selected one.
IGNORE, when non-nil means a window can be returned even if its
`no-other-window' parameter is non-nil."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(unless (memq direction '(above below left right))
(error "Wrong direction %s" direction))
(let* ((frame (window-frame window))
@@ -1486,7 +1498,7 @@ This function resizes other windows proportionally and never
deletes any windows. If you want to move only the low (right)
edge of WINDOW consider using `adjust-window-trailing-edge'
instead."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let* ((frame (window-frame window))
sibling)
(cond
@@ -2005,7 +2017,7 @@ If DELTA is greater zero, then move the edge downwards or to the
right. If DELTA is less than zero, move the edge upwards or to
the left. If the edge can't be moved by DELTA lines or columns,
move it as far as possible in the desired direction."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let ((frame (window-frame window))
(right window)
left this-delta min-delta max-delta failed)
@@ -2152,7 +2164,7 @@ Return nil."
Make WINDOW as large as possible without deleting any windows.
WINDOW can be any window and defaults to the selected window."
(interactive)
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(window-resize window (window-max-delta window))
(window-resize window (window-max-delta window t) t))
@@ -2161,7 +2173,7 @@ WINDOW can be any window and defaults to the selected window."
Make WINDOW as small as possible without deleting any windows.
WINDOW can be any window and defaults to the selected window."
(interactive)
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(window-resize window (- (window-min-delta window)))
(window-resize window (- (window-min-delta window t)) t))
@@ -2317,7 +2329,7 @@ and no others."
"Return t if WINDOW can be safely deleted from its frame.
Return `frame' if deleting WINDOW should also delete its
frame."
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(unless ignore-window-parameters
;; Handle atomicity.
@@ -2367,7 +2379,7 @@ Otherwise, if WINDOW is part of an atomic window, call
argument. If WINDOW is the only window on its frame or the last
non-side window, signal an error."
(interactive)
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let* ((frame (window-frame window))
(function (window-parameter window 'delete-window))
(parent (window-parent window))
@@ -2448,7 +2460,7 @@ WINDOW is a non-side window, make WINDOW the only non-side window
on the frame. Side windows are not deleted. If WINDOW is a side
window signal an error."
(interactive)
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let* ((frame (window-frame window))
(function (window-parameter window 'delete-other-windows))
(window-side (window-parameter window 'window-side))
@@ -2530,7 +2542,7 @@ This may be a useful alternative binding for \\[delete-other-windows]
(defun record-window-buffer (&optional window)
"Record WINDOW's buffer.
WINDOW must be a live window and defaults to the selected one."
- (let* ((window (window-normalize-live-window window))
+ (let* ((window (window-normalize-window window t))
(buffer (window-buffer window))
(entry (assq buffer (window-prev-buffers window))))
;; Reset WINDOW's next buffers. If needed, they are resurrected by
@@ -2566,7 +2578,7 @@ WINDOW must be a live window and defaults to the selected one."
WINDOW must be a live window and defaults to the selected one.
BUFFER must be a live buffer and defaults to the buffer of
WINDOW."
- (let* ((window (window-normalize-live-window window))
+ (let* ((window (window-normalize-window window t))
(buffer (or buffer (window-buffer window))))
(set-window-prev-buffers
window (assq-delete-all buffer (window-prev-buffers window)))
@@ -2599,7 +2611,7 @@ Optional argument BURY-OR-KILL non-nil means the buffer currently
shown in WINDOW is about to be buried or killed and consequently
shall not be switched to in future invocations of this command."
(interactive)
- (let* ((window (window-normalize-live-window window))
+ (let* ((window (window-normalize-window window t))
(old-buffer (window-buffer window))
;; Save this since it's destroyed by `set-window-buffer'.
(next-buffers (window-next-buffers window))
@@ -2688,7 +2700,7 @@ shall not be switched to in future invocations of this command."
"In WINDOW switch to next buffer.
WINDOW must be a live window and defaults to the selected one."
(interactive)
- (let* ((window (window-normalize-live-window window))
+ (let* ((window (window-normalize-window window t))
(old-buffer (window-buffer window))
(next-buffers (window-next-buffers window))
new-buffer entry killed-buffers visible)
@@ -2811,7 +2823,7 @@ Optional argument DEDICATED-ONLY non-nil means to delete WINDOW
only if it's dedicated to its buffer. Optional argument KILL
means the buffer shown in window will be killed. Return non-nil
if WINDOW gets deleted or its frame is auto-hidden."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(unless (and dedicated-only (not (window-dedicated-p window)))
(let* ((buffer (window-buffer window))
(deletable (window-deletable-p window)))
@@ -2957,7 +2969,7 @@ WINDOW, \(3) restore the buffer previously displayed in WINDOW,
or \(4) make WINDOW display some other buffer than the present
one. If non-nil, reset `quit-restore' parameter to nil."
(interactive "P")
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(let* ((buffer (window-buffer window))
(quit-restore (window-parameter window 'quit-restore))
(prev-buffer
@@ -3089,7 +3101,7 @@ window, these properties as well as the buffer displayed in the
new window are inherited from the window selected on WINDOW's
frame. The selected window is not changed by this function."
(interactive "i")
- (setq window (window-normalize-any-window window))
+ (setq window (window-normalize-window window))
(let* ((side (cond
((not side) 'below)
((memq side '(below above right left)) side)
@@ -3663,7 +3675,7 @@ to put the state recorded here into an arbitrary window. The
value can be also stored on disk and read back in a new session."
(setq window
(if window
- (if (window-any-p window)
+ (if (window-valid-p window)
window
(error "%s is not a live or internal window" window))
(frame-root-window)))
@@ -3833,7 +3845,7 @@ Optional argument IGNORE non-nil means ignore minimum window
sizes and fixed size restrictions. IGNORE equal `safe' means
subwindows can get as small as `window-safe-min-height' and
`window-safe-min-width'."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(let* ((frame (window-frame window))
(head (car state))
;; We check here (1) whether the total sizes of root window of
@@ -5099,7 +5111,7 @@ Note that the current implementation of this function cannot
always set the height exactly, but attempts to be conservative,
by allocating more lines than are actually needed in the case
where some error may be present."
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
(let ((delta (- height (window-text-height window))))
(unless (zerop delta)
;; Setting window-min-height to a value like 1 can lead to very
@@ -5195,7 +5207,7 @@ WINDOW was scrolled."
(interactive)
;; Do all the work in WINDOW and its buffer and restore the selected
;; window and the current buffer when we're done.
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
;; Can't resize a full height or fixed-size window.
(unless (or (window-size-fixed-p window)
(window-full-height-p window))
@@ -5301,7 +5313,7 @@ window, or if the window is the only window of its frame.
Return non-nil if the window was shrunk, nil otherwise."
(interactive)
- (setq window (window-normalize-live-window window))
+ (setq window (window-normalize-window window t))
;; Make sure that WINDOW is vertically combined and `point-min' is
;; visible (for whatever reason that's needed). The remaining issues
;; should be taken care of by `fit-window-to-buffer'.