After thinking about it, I am wondering if the current behavior of 'window-lines-pixel-dimensions' is correct ? As user of the function I do not expect the function to count glyphs that are inserted by redisplay only "for its own purpose", glyphs that are invisible and non-existent for the end user. IMHO, for an empty line, 'window-lines-pixel-dimensions' should return the width 0. A line with X characters should have the width of all thoses characters. I see that 'window-largest-empty-rectangle' uses this function, the widths of the rectangles it returns are smaller than they really are. I think it makes sense to change this behavior and make 'window-lines-pixel-dimensions' not counting these "redisplay only" glyphs. Thus, there would be no need for a new argument to the function. > Agreed. Sébastien can you try to show "that using the glyph matrices > is much faster"? I tested the following code: ``` (defmacro time (&rest forms) (let ((t1 (make-symbol "t1"))) `(let (,t1) (redisplay t) (setq ,t1 (current-time)) ,@forms (float-time (time-since ,t1))))) (defun test1 nil (window-lines-pixel-dimensions nil nil nil t)) (defun test2 nil (save-excursion (goto-char (window-start)) (let ((index 1) (height (window-body-height))) (while (<= index height) (window-text-pixel-size nil (line-beginning-position index) (line-end-position index)) (setq index (1+ index)) )))) ``` `(time (test1))` returns 0.000004869 `(time (test2))` returns 0.00376 Le sam. 9 nov. 2019 à 02:27, martin rudalics a écrit : > > In general, functions that use only the glyph matrices have a > > significant disadvantage in that they will fail when display is not up > > to date, something that can happen out of control of a Lisp program > > that calls the function. So I very much prefer window-text-pixel-size > > to an alternative that uses the glyph matrices. If we find that using > > the glyph matrices is much faster, then I'd prefer to fix > > window-text-pixel-size to use the glyph matrices when possible, and > > otherwise fall back to its current method. See move-point-visually > > for one example of how this can be done. > > Agreed. Sébastien can you try to show "that using the glyph matrices > is much faster"? > > martin > >