diff --git a/lisp/window.el b/lisp/window.el index e806677..5a836b0 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2093,15 +2093,16 @@ window-font-width If FACE is nil or omitted, the default face is used. If FACE is remapped (see `face-remapping-alist'), the function returns the information for the remapped face." - (with-selected-window (window-normalize-window window t) - (if (display-multi-font-p) + (setq window (window-normalize-window window t)) + (let ((frame (window-frame window))) + (if (display-multi-font-p frame) (let* ((face (if face face 'default)) - (info (font-info (face-font face))) + (info (font-info (face-font face frame))) (width (aref info 11))) (if (> width 0) - width + width (aref info 10))) - (frame-char-width)))) + (frame-char-width frame)))) (defun window-font-height (&optional window face) "Return character height for the font of FACE used in WINDOW. @@ -2110,12 +2111,13 @@ window-font-height If FACE is nil or omitted, the default face is used. If FACE is remapped (see `face-remapping-alist'), the function returns the information for the remapped face." - (with-selected-window (window-normalize-window window t) - (if (display-multi-font-p) + (setq window (window-normalize-window window t)) + (let ((frame (window-frame window))) + (if (display-multi-font-p frame) (let* ((face (if face face 'default)) - (info (font-info (face-font face)))) + (info (font-info (face-font face frame)))) (aref info 3)) - (frame-char-height)))) + (frame-char-height frame)))) (defvar overflow-newline-into-fringe) @@ -2132,26 +2134,28 @@ window-max-chars-per-line ways. First, it accounts for the portions of the line reserved for the continuation glyph. Second, it accounts for the size of the font." - (with-selected-window (window-normalize-window window t) - (let* ((window-width (window-body-width window t)) - (font-width (window-font-width window face)) - (ncols (/ window-width font-width))) - (if (and (display-graphic-p) - overflow-newline-into-fringe - (not - (or (eq left-fringe-width 0) - (and (null left-fringe-width) - (= (frame-parameter nil 'left-fringe) 0)))) - (not - (or (eq right-fringe-width 0) - (and (null right-fringe-width) - (= (frame-parameter nil 'right-fringe) 0))))) - ncols - ;; FIXME: This should remove 1 more column when there are no - ;; fringes, lines are truncated, and the window is hscrolled, - ;; but EOL is not in the view, because then there are 2 - ;; truncation glyphs, not one. - (1- ncols))))) + (setq window (window-normalize-window window t)) + (let* ((frame (window-frame window)) + (window-width (window-body-width window t)) + (font-width (window-font-width window face)) + (ncols (/ window-width font-width))) + (if (and (display-graphic-p frame) + (with-current-buffer (window-buffer window) + (and overflow-newline-into-fringe + (not + (or (eq left-fringe-width 0) + (and (null left-fringe-width) + (= (frame-parameter frame 'left-fringe) 0)))) + (not + (or (eq right-fringe-width 0) + (and (null right-fringe-width) + (= (frame-parameter frame 'right-fringe) 0))))))) + ncols + ;; FIXME: This should remove 1 more column when there are no + ;; fringes, lines are truncated, and the window is hscrolled, + ;; but EOL is not in the view, because then there are 2 + ;; truncation glyphs, not one. + (1- ncols)))) (defun window-current-scroll-bars (&optional window) "Return the current scroll bar types for WINDOW.