all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 20847@debbugs.gnu.org
Subject: bug#20847: [display engine] 25.0.50; company-mode popup makes point jump to an entirely different location
Date: Mon, 29 Jun 2015 18:48:09 +0300	[thread overview]
Message-ID: <559168B9.8070403@yandex.ru> (raw)
In-Reply-To: <83pp4ldqq9.fsf@gnu.org>

On 06/24/2015 07:18 PM, Eli Zaretskii wrote:

> Yes, and I was asking whether in this specific case it could refrain
> from doing that.  (And yes, I understand that doing so would be
> additional complexity for you.)

Probably yes. But the problem is not only in complexity, but also in the 
lack of testability (it's not easy to write automatic checks to see if 
each case behaves as expected; or rather, virtually impossible).

Chiefly, I need a reliable predicate. Say I have computed the current 
visual column of point. What do I compare it to?

We have this function to determine the "usable" part of the window's width:

(defun company--window-width ()
   (let ((ww (window-body-width)))
     ;; Account for the line continuation column.
     (when (zerop (cadr (window-fringes)))
       (cl-decf ww))
     (unless (or (display-graphic-p)
                 (version< "24.3.1" emacs-version))
       ;; Emacs 24.3 and earlier included margins
       ;; in window-width when in TTY.
       (cl-decf ww
                (let ((margins (window-margins)))
                  (+ (or (car margins) 0)
                     (or (cdr margins) 0)))))
     (when (and word-wrap
                (version< emacs-version "24.4.51.5"))
       ;; http://debbugs.gnu.org/19300
       (cl-decf ww))
     ;; whitespace-mode with newline-mark
     (when (and buffer-display-table
                (aref buffer-display-table ?\n))
       (cl-decf ww (1- (length (aref buffer-display-table ?\n)))))
     ww))

Do I compare the visual column against the value it returns, or against 
straight (window-body-width), or against something in between?

> Yes, it did.  When the display engine needs to decide where to put the
> cursor, it examines all the screen lines whose buffer positions are
> around point.  So in this case, it did examine all those lines that
> came from an overlay string, and rejected them all.

We could say that if the positions were rejected for other reasons, 
then, for the purposes of this discussion, they weren't considered for 
displaying the cursor at.

> That's correct, but the heuristic applies to the line where the
> overlay string ends, when it ends with a newline that comes from the
> overlay string.  When this happens, we could place the cursor either
> at the end of the line with that newline, or at the beginning of the
> next line.  We prefer the latter.

Why not prefer the former? And use the margin if the cursor goes behind 
the edge as a result.

Unless there are cases which would lead to accidental point movements 
with this choice as well, this would seem like a better one.

> I tried to do that, but unfortunately, when the display engine gets to
> the point where it needs to place the cursor, it lacks information for
> treating this situation specially.  That's because the information
> about the overlay is long gone, and the newline didn't leave any
> glyphs on the screen.

How is the heuristic applied, then? It somehow needs to know, IIUC, that 
a string coming from a overlay is there.

> Yes.  And that's exactly the problem: we would like to treat this case
> differently, but don't have the necessary information to do so.
>
> What I need to do so is (1) the starting and ending point of the
> overlay which begot the string, and (2) the fact that the string
> begins with a newline, or some handle for the string itself.  None of
> that is available at the point where we decide whether this line is
> "appropriate" for the cursor.

Maybe the decision where to put the cursor should be made earlier, then.

> It's not up to me, it's up to you.  If you want to understand the gory
> details without myself standing in between (and maybe describing some
> things inaccurately or not clearly enough), then I will gladly tell
> you where to look.  I'm also okay with describing it for you as best I
> can, like I did until now.  It's your call.

I wouldn't mind taking a glance (just out of curiosity, or for a distant 
future reference), but you'll most likely have to continue translating 
anyway.





  reply	other threads:[~2015-06-29 15:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19  1:04 bug#20847: [display engine] 25.0.50; company-mode popup makes point jump to an entirely different location Dmitry Gutov
2015-06-19 19:07 ` Eli Zaretskii
2015-06-20 11:51   ` Eli Zaretskii
2015-06-21 13:56     ` Dmitry Gutov
2015-06-21 16:43       ` Eli Zaretskii
2015-06-21 18:06         ` Dmitry Gutov
2015-06-21 18:24           ` Eli Zaretskii
2015-06-21 19:23             ` Eli Zaretskii
2015-06-21 20:17               ` Dmitry Gutov
2015-06-21 20:02             ` Dmitry Gutov
2015-06-22  2:45               ` Eli Zaretskii
2015-06-22 11:01                 ` Dmitry Gutov
2015-06-22 13:40                 ` Dmitry Gutov
2015-06-22 16:26                   ` Eli Zaretskii
2015-06-22 21:06                     ` Dmitry Gutov
2015-06-23 16:39                       ` Eli Zaretskii
2015-06-23 18:44                         ` Dmitry Gutov
2015-06-23 19:07                           ` Eli Zaretskii
2015-06-23 21:15                             ` Dmitry Gutov
2015-06-24 16:18                               ` Eli Zaretskii
2015-06-29 15:48                                 ` Dmitry Gutov [this message]
2015-06-30 17:46                                   ` Eli Zaretskii
2015-06-30 19:41                                     ` Dmitry Gutov
2015-06-30 20:11                                       ` Eli Zaretskii
2015-06-30 20:20                                         ` Dmitry Gutov
2015-07-01  2:42                                           ` Eli Zaretskii
2015-07-01 10:21                                             ` Dmitry Gutov
2015-07-01 15:16                                               ` Eli Zaretskii
2015-07-01 16:36                                                 ` Dmitry Gutov
2015-07-01 16:40                                                   ` Eli Zaretskii
2015-06-21 13:30   ` Dmitry Gutov
2015-06-21 14:16     ` Dmitry Gutov
2015-06-21 16:24     ` Eli Zaretskii
2015-06-21 17:46       ` Dmitry Gutov
2015-06-21 18:09         ` Eli Zaretskii
2015-06-21 20:01           ` Dmitry Gutov
2015-06-22  2:43             ` Eli Zaretskii
2015-06-22 10:57               ` Dmitry Gutov
2015-06-22 16:23                 ` Eli Zaretskii
2015-06-23  0:15                   ` Dmitry Gutov

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=559168B9.8070403@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=20847@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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.