GNU bug report logs - #18504
24.3.93; posn-at-point intermittently returns wrong value for a valid buffer position

Previous Next

Package: emacs;

Reported by: Dmitry <dgutov <at> yandex.ru>

Date: Fri, 19 Sep 2014 01:02:02 UTC

Severity: normal

Found in version 24.3.93

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 18504 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18504 <at> debbugs.gnu.org
Subject: Re: bug#18504: 24.3.93;	posn-at-point intermittently returns wrong
 value for a valid buffer	position
Date: Fri, 19 Sep 2014 17:46:57 +0400
On 09/19/2014 05:35 PM, Eli Zaretskii wrote:

> Btw, why is it important what happens when the user types C-g, i.e. if
> she abandons the completion?  Or does the problem happen without C-g
> as well?

I'm not quite sure how we get to that point, to be honest. The code gets 
called from `company-post-command' (which is in post-command-hook), but 
this-command is nil when that happens.

>> If `posn-at-point' is itself stateless (and doesn't modify any relevant
>> caches), why not call it again at that point?
>
> Because it will most probably produce the correct result.
>
> But you can try that yourself: insert a second call under the
> conditions that you know are evidence of the problem.  If that is
> repeatable, i.e. if that second call always produces the wrong result,
> then I have what I need.

It is. Try this:

diff --git a/company.el b/company.el
index fdf09f7..01a3cb5 100644
--- a/company.el
+++ b/company.el
@@ -782,7 +782,13 @@ means that `company-mode' is always turned on 
except in `message-mode' buffers."
     (cons (+ col (window-hscroll)) row)))

 (defun company--col-row (&optional pos)
-  (company--posn-col-row (posn-at-point pos)))
+  (let ((posn (posn-at-point pos)))
+    ;; Completion should be invoked at column > 1.
+    (when (zerop (car (posn-x-y posn)))
+      (message "company--col-row zero!")
+      (message "then:")
+      (message "%s" (posn-x-y (posn-at-point pos))))
+    (company--posn-col-row posn)))

 (defun company--row (&optional pos)
   (cdr (company--col-row pos)))

I get:

company--col-row zero!
then:
(0 . 198)




This bug report was last modified 10 years and 248 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.