all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Sébastien Chapuis" <sebastien@chapu.is>
To: martin rudalics <rudalics@gmx.at>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: [PATCH] Add function window-line-width
Date: Sun, 10 Nov 2019 06:09:56 +0800	[thread overview]
Message-ID: <CAN2HsvzYXmb0NRbkjFZy34yQ+ojOaSMZQ+-1EY2C8Xq-tf=UQw@mail.gmail.com> (raw)
In-Reply-To: <ae3b26ea-cf92-a64e-052b-3358bc99c932@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 2435 bytes --]

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 <rudalics@gmx.at> 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
>
>

[-- Attachment #2: Type: text/html, Size: 3244 bytes --]

  reply	other threads:[~2019-11-09 22:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 22:49 [PATCH] Add function window-line-width Sébastien Chapuis
2019-11-07  8:40 ` martin rudalics
2019-11-07  8:50   ` martin rudalics
2019-11-08  4:54     ` Sébastien Chapuis
2019-11-08  9:21       ` martin rudalics
2019-11-08 13:18         ` Eli Zaretskii
2019-11-08 18:27           ` martin rudalics
2019-11-09 22:09             ` Sébastien Chapuis [this message]
2019-11-10  9:46               ` martin rudalics
2019-11-10 19:02                 ` Sébastien Chapuis
2019-11-14 10:08                   ` Eli Zaretskii
2019-11-14  9:11               ` Eli Zaretskii
2019-11-07  9:23 ` Robert Pluim

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN2HsvzYXmb0NRbkjFZy34yQ+ojOaSMZQ+-1EY2C8Xq-tf=UQw@mail.gmail.com' \
    --to=sebastien@chapu.is \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /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 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.