]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #18384 with incorrect reporting of row number by posn-col-row.
authorEli Zaretskii <eliz@gnu.org>
Tue, 2 Sep 2014 15:16:42 +0000 (18:16 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 2 Sep 2014 15:16:42 +0000 (18:16 +0300)
 lisp/subr.el (posn-col-row): Revert the change from commit
 2010-11-13T21:07:58Z!eliz@gnu.org, which
 was inadvertently merged from emacs-23 release branch in
2010-11-18T03:54:14Z!monnier@iro.umontreal.ca, and
 introduced an off-by-one error in the reported row when there is a
 header line.

 src/dispnew.c (buffer_posn_from_coords): Fix an off-by-one error in
 the reported row in the case of a window with a header line, by
 improving on the fix committed in 2011-10-08T10:58:50Z!eliz@gnu.org
 eliz@gnu.org-20111008105850-ht4tvsayohvr1kjc.

lisp/ChangeLog
lisp/subr.el
src/ChangeLog
src/dispnew.c

index 70e5ade2eee215cca1006b7a04bf7e7fb2d4a9ac..f729f42da87561cccee9281bb41a83e9fdbcd3fb 100644 (file)
@@ -1,3 +1,12 @@
+2014-09-02  Eli Zaretskii  <eliz@gnu.org>
+
+       * subr.el (posn-col-row): Revert the change from commit
+       2010-11-13T21:07:58Z!eliz@gnu.org, which
+       was inadvertently merged from emacs-23 release branch in 2010-11-18T03:54:14Z!monnier@iro.umontreal.ca
+       monnier@iro.umontreal.ca-20101118035414-yvlg7k7dk4k4l3q, and
+       introduced an off-by-one error in the reported row when there is a
+       header line.  (Bug#18384)
+
 2014-09-01  Fabián Ezequiel Gallina  <fgallina@gnu.org>
 
        * progmodes/python.el (python-indent-post-self-insert-function):
index 116032fd0bab1baa55569666a62edca11506cd38..089e3efe79c80a3647738e80910cf635838a8b4c 100644 (file)
@@ -1146,10 +1146,7 @@ and `event-end' functions."
              ((null spacing)
               (setq spacing 0)))
        (cons (/ (car pair) (frame-char-width frame))
-             (- (/ (cdr pair) (+ (frame-char-height frame) spacing))
-                (if (null (with-current-buffer (window-buffer window)
-                            header-line-format))
-                    0 1))))))))
+             (/ (cdr pair) (+ (frame-char-height frame) spacing))))))))
 
 (defun posn-actual-col-row (position)
   "Return the actual column and row in POSITION, measured in characters.
index 5e3ec8aa597a6b09eb074fef9850b3628dd123ac..5f00b654261c856b046311611c016f5703435fdf 100644 (file)
@@ -1,3 +1,10 @@
+2014-09-02  Eli Zaretskii  <eliz@gnu.org>
+
+       * dispnew.c (buffer_posn_from_coords): Fix an off-by-one error in
+       the reported row in the case of a window with a header line, by
+       improving on the fix committed in 2011-10-08T10:58:50Z!eliz@gnu.org
+       eliz@gnu.org-20111008105850-ht4tvsayohvr1kjc.  (Bug#18384)
+
 2014-09-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        * eval.c (internal_lisp_condition_case): Don't overrun the stack
index e6ab5bf1e9c7dfb2a273d1ba9a479bf40426b45b..9725068c72b1f3f2f5e48bdfb98c5e3ee1dbbaaa 100644 (file)
@@ -5107,7 +5107,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
 #ifdef HAVE_WINDOW_SYSTEM
   struct image *img = 0;
 #endif
-  int x0, x1, to_x;
+  int x0, x1, to_x, it_vpos;
   void *itdata = NULL;
 
   /* We used to set current_buffer directly here, but that does the
@@ -5116,11 +5116,6 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
   itdata = bidi_shelve_cache ();
   CLIP_TEXT_POS_FROM_MARKER (startp, w->start);
   start_display (&it, w, startp);
-  /* start_display takes into account the header-line row, but IT's
-     vpos still counts from the glyph row that includes the window's
-     start position.  Adjust for a possible header-line row.  */
-  it.vpos += WINDOW_WANTS_HEADER_LINE_P (w);
-
   x0 = *x;
 
   /* First, move to the beginning of the row corresponding to *Y.  We
@@ -5190,8 +5185,13 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
     }
 #endif
 
-  if (it.vpos < w->current_matrix->nrows
-      && (row = MATRIX_ROW (w->current_matrix, it.vpos),
+  /* IT's vpos counts from the glyph row that includes the window's
+     start position, i.e. it excludes the header-line row, but
+     MATRIX_ROW includes the header-line row.  Adjust for a possible
+     header-line row.  */
+  it_vpos = it.vpos + WINDOW_WANTS_MODELINE_P (w);
+  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])