summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-09-02 18:16:42 +0300
committerEli Zaretskii <eliz@gnu.org>2014-09-02 18:16:42 +0300
commit5735a30d59af16ba004a151b6e0a4c18ba1d481e (patch)
treec67e14bbc54df245f8109485677589362031844d
parent5597a7d4e2a69b6777c023e0eae888b7ffd7d566 (diff)
downloademacs-5735a30d59af16ba004a151b6e0a4c18ba1d481e.tar.gz
Fix bug #18384 with incorrect reporting of row number by posn-col-row.
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.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/subr.el5
-rw-r--r--src/ChangeLog7
-rw-r--r--src/dispnew.c16
4 files changed, 25 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 70e5ade2eee..f729f42da87 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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):
diff --git a/lisp/subr.el b/lisp/subr.el
index 116032fd0ba..089e3efe79c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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.
diff --git a/src/ChangeLog b/src/ChangeLog
index 5e3ec8aa597..5f00b654261 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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
diff --git a/src/dispnew.c b/src/dispnew.c
index e6ab5bf1e9c..9725068c72b 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -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])