unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4426: 23.0.91; posn-at-point returns an incorrect value
@ 2009-09-14  9:18 IRIE Shinsuke
  2010-03-17  4:01 ` bug#4426: [PATCH] " IRIE Shinsuke
  0 siblings, 1 reply; 5+ messages in thread
From: IRIE Shinsuke @ 2009-09-14  9:18 UTC (permalink / raw)
  To: bug-gnu-emacs

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@yahoo.co.jp






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4426: [PATCH] posn-at-point returns an incorrect value
  2009-09-14  9:18 bug#4426: 23.0.91; posn-at-point returns an incorrect value IRIE Shinsuke
@ 2010-03-17  4:01 ` IRIE Shinsuke
  2011-09-18  8:21   ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: IRIE Shinsuke @ 2010-03-17  4:01 UTC (permalink / raw)
  To: 4426

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

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

[-- Attachment #2: fix_bug4426.patch --]
[-- Type: text/x-diff, Size: 1007 bytes --]

=== modified file 'src/dispnew.c'
*** old/src/dispnew.c	2010-03-16 14:48:29 +0000
--- new/src/dispnew.c	2010-03-16 16:06:28 +0000
***************
*** 5937,5942 ****
--- 5937,5943 ----
    Lisp_Object old_current_buffer = Fcurrent_buffer ();
    struct text_pos startp;
    Lisp_Object string;
+   int matrix_vpos;
    struct glyph_row *row;
  #ifdef HAVE_WINDOW_SYSTEM
    struct image *img = 0;
***************
*** 5974,5981 ****
      }
  #endif
  
!   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])


^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4426: [PATCH] posn-at-point returns an incorrect value
  2010-03-17  4:01 ` bug#4426: [PATCH] " IRIE Shinsuke
@ 2011-09-18  8:21   ` Lars Magne Ingebrigtsen
  2011-09-18  9:22     ` Eli Zaretskii
  2011-10-08 11:01     ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-18  8:21 UTC (permalink / raw)
  To: irieshinsuke; +Cc: 4426

IRIE Shinsuke <irieshinsuke@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/





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4426: [PATCH] posn-at-point returns an incorrect value
  2011-09-18  8:21   ` Lars Magne Ingebrigtsen
@ 2011-09-18  9:22     ` Eli Zaretskii
  2011-10-08 11:01     ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2011-09-18  9:22 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 4426

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 18 Sep 2011 10:21:43 +0200
> Cc: 4426@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4426: [PATCH] posn-at-point returns an incorrect value
  2011-09-18  8:21   ` Lars Magne Ingebrigtsen
  2011-09-18  9:22     ` Eli Zaretskii
@ 2011-10-08 11:01     ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2011-10-08 11:01 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 4426-done

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 18 Sep 2011 10:21:43 +0200
> Cc: 4426@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-08 11:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14  9:18 bug#4426: 23.0.91; posn-at-point returns an incorrect value IRIE Shinsuke
2010-03-17  4:01 ` bug#4426: [PATCH] " IRIE Shinsuke
2011-09-18  8:21   ` Lars Magne Ingebrigtsen
2011-09-18  9:22     ` Eli Zaretskii
2011-10-08 11:01     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).