GNU bug report logs - #4426
23.0.91; posn-at-point returns an incorrect value

Previous Next

Package: emacs;

Reported by: irieshinsuke <at> yahoo.co.jp

Date: Mon, 14 Sep 2009 09:25:04 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4426 in the body.
You can then email your comments to 4426 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4426; Package emacs. (Mon, 14 Sep 2009 09:25:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to irieshinsuke <at> yahoo.co.jp:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 14 Sep 2009 09:25:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.0.91; posn-at-point returns an incorrect value
Date: Mon, 14 Sep 2009 18:18:47 +0900
I was going to acquire the width and height of a character the cursor
is over, by using the following code:

  (posn-object-width-height (posn-at-point))

However, I found that this code gives back a wrong result when a
header line is displayed such as tabbar-mode. This code returns the
size of another character, which is in the position different from the
exact one in the number of objects included in the header line.
For example, when the cursor is in the top left corner of the window,
the size of the object in the left end of the header line is obtained.

Steps to reproduce:

  1. Turn on tabbar-mode.

  2. Evaluate the following expressions in *scratch*:

       (defun char-w-h ()
         (message "%s" (posn-object-width-height (posn-at-point))))
       (add-hook 'post-command-hook 'char-w-h)

  3. Move a cursor from place to place in the window.


In GNU Emacs 23.0.91.1 (i486-pc-linux-gnu, GTK+ Version 2.16.0)
 of 2009-04-05 on palmer, modified by Debian
 (emacs-snapshot package, version 1:20090320-1ubuntu1)
Windowing system distributor `The X.Org Foundation', version 11.0.10600000
configured using `configure  '--build' 'i486-linux-gnu' '--host'
'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.0.91/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.0.91/site-lisp:/usr/share/emacs/site-lisp'
'--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=i486-linux-gnu'
'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN
-DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed'
'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ja_JP.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tabbar-mwheel-mode: t
  tabbar-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
u i r e SPC ' t C-p C-p C-p C-p C-p C-p C-p C-n C-n
C-n C-n C-n C-f C-f C-f C-f C-f C-f C-f C-f C-b C-b
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-n
C-n C-e a b b a r ) C-j ( t a b b a r - m o d e ) C-j
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-n C-p C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f
C-f C-f C-f C-f C-f C-n C-p C-p C-b C-b C-b C-b C-b
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-n C-n C-n
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n C-n
C-n C-p C-p C-p C-p C-p C-n C-n C-b C-p C-p C-n C-a
C-f C-f C-f C-f C-f C-f C-p C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-a C-a C-f C-f C-f
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n ( r e m o v
e - h o o k SPC ' p o s t - c o m m a n d - h o o k
SPC ' c h a r - w - h ) C-j M-x r e p o r t - e m a
<tab> RET

Recent messages:
(7 . 14) [3 times]
(0 . 14)
(7 . 14)
(0 . 14)
(7 . 14)
(0 . 14)
(7 . 14)
(0 . 14)
(7 . 14) [3 times]
(0 . 14) [41 times]

-- 
IRIE Shinsuke, Ph.D.
irieshinsuke <at> yahoo.co.jp




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4426; Package emacs. (Thu, 17 Sep 2009 04:40:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to irieshinsuke <at> yahoo.co.jp:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 17 Sep 2009 04:40:05 GMT) Full text and rfc822 format available.

Message #10 received at 4426 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: 4426 <at> debbugs.gnu.org
Subject: bug#4426: Further information
Date: Thu, 17 Sep 2009 13:30:36 +0900
I confirmed that this behavior also happens in Emacs 23.1.50.1,
23.1.1 and 22.2.1.

-- 
IRIE Shinsuke, Ph.D.
irieshinsuke <at> yahoo.co.jp



Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#4426; Package emacs. (Wed, 17 Mar 2010 04:02:02 GMT) Full text and rfc822 format available.

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

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: 4426 <at> debbugs.gnu.org
Subject: bug#4426: [PATCH] posn-at-point returns an incorrect value
Date: Wed, 17 Mar 2010 13:01:59 +0900
[Message part 1 (text/plain, inline)]
6 months ago I reported bug #4426, that is, `posn-at-point' returns
incorrect value when header line is displayed. I've investigated this
bug and found the solution.

I describe again this bug:

   If header line is displayed, `posn-object-width-height' incorrectly
   returns the size of object in position different from specified one.

   For example, an expression

     (posn-object-width-height (posn-at-point (window-start)))

   must return the width and height of character on the top left corner
   of text area, but actually returns the ones on the beginning of
   header line.

It turned out that this problem occurs as a result of confusion between
it.vpos and MATRIX_ROW_VPOS in a function buffer_posn_from_coords
(included in dispnew.c).

So I wrote the small patch to fix this bug. Please check it.


IRIE Shinsuke
[fix_bug4426.patch (text/x-diff, attachment)]

Added tag(s) patch. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 18 Sep 2011 08:28:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4426; Package emacs. (Sun, 18 Sep 2011 08:50:02 GMT) Full text and rfc822 format available.

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

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: irieshinsuke <at> yahoo.co.jp
Cc: 4426 <at> debbugs.gnu.org
Subject: Re: bug#4426: [PATCH] posn-at-point returns an incorrect value
Date: Sun, 18 Sep 2011 10:21:43 +0200
IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp> writes:

>    If header line is displayed, `posn-object-width-height' incorrectly
>    returns the size of object in position different from specified one.
>
>    For example, an expression
>
>      (posn-object-width-height (posn-at-point (window-start)))
>
>    must return the width and height of character on the top left corner
>    of text area, but actually returns the ones on the beginning of
>    header line.
>
> It turned out that this problem occurs as a result of confusion between
> it.vpos and MATRIX_ROW_VPOS in a function buffer_posn_from_coords
> (included in dispnew.c).
>
> So I wrote the small patch to fix this bug. Please check it.

[...]

> !   if (it.vpos < w->current_matrix->nrows
> !       && (row = MATRIX_ROW (w->current_matrix, it.vpos),
>   	  row->enabled_p))
>       {
>         if (it.hpos < row->used[TEXT_AREA])
> --- 5975,5984 ----
>       }
>   #endif
>   
> !   /* it.vpos isn't the same as MATRIX_ROW_VPOS if header line is displayed */
> !   matrix_vpos = (w->current_matrix->rows->mode_line_p ? 1 : 0) + it.vpos;
> !   if (matrix_vpos < w->current_matrix->nrows
> !       && (row = MATRIX_ROW (w->current_matrix, matrix_vpos),
>   	  row->enabled_p))
>       {
>         if (it.hpos < row->used[TEXT_AREA])

As far as I can tell, this patch hasn't been applied yet.  I'm not
familiar enough with this code to say whether this looks correct or
not.  Could someone take a look?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4426; Package emacs. (Sun, 18 Sep 2011 09:28:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: irieshinsuke <at> yahoo.co.jp, 4426 <at> debbugs.gnu.org
Subject: Re: bug#4426: [PATCH] posn-at-point returns an incorrect value
Date: Sun, 18 Sep 2011 05:22:35 -0400
> From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
> Date: Sun, 18 Sep 2011 10:21:43 +0200
> Cc: 4426 <at> debbugs.gnu.org
> 
> As far as I can tell, this patch hasn't been applied yet.  I'm not
> familiar enough with this code to say whether this looks correct or
> not.  Could someone take a look?

Is the original problem still present?  AFAIR, Chong fixed something
similar some time ago.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 08 Oct 2011 11:02:02 GMT) Full text and rfc822 format available.

Notification sent to irieshinsuke <at> yahoo.co.jp:
bug acknowledged by developer. (Sat, 08 Oct 2011 11:02:03 GMT) Full text and rfc822 format available.

Message #26 received at 4426-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 4426-done <at> debbugs.gnu.org, irieshinsuke <at> yahoo.co.jp
Subject: Re: bug#4426: [PATCH] posn-at-point returns an incorrect value
Date: Sat, 08 Oct 2011 13:01:06 +0200
> From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
> Date: Sun, 18 Sep 2011 10:21:43 +0200
> Cc: 4426 <at> debbugs.gnu.org
> 
> As far as I can tell, this patch hasn't been applied yet.  I'm not
> familiar enough with this code to say whether this looks correct or
> not.  Could someone take a look?

I took a look.  The problem indeed was still there.  I installed a fix
(slightly different from what the OP suggested).

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 05 Nov 2011 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 168 days ago.

Previous Next


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