]> code.delx.au - gnu-emacs/commitdiff
Fix line-move-visual's following of column in R2L lines.
authorEli Zaretskii <eliz@gnu.org>
Thu, 8 Jan 2015 14:04:46 +0000 (16:04 +0200)
committerEli Zaretskii <eliz@gnu.org>
Thu, 8 Jan 2015 14:04:46 +0000 (16:04 +0200)
 src/simple.el (line-move-visual): When converting X pixel coordinate
 to temporary-goal-column, adjust the value for right-to-left
 screen lines.  This fixes vertical-motion, next/prev-line, etc.

 src/dispnew.c (buffer_posn_from_coords): Fix the value of the column
 returned for right-to-left screen lines.  (Before the change on
 2014-12-30, the incorrectly-computed X pixel coordinate concealed
 this bug.)

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

index 56a1c39317aafbc75583a28db1f576083a4d127e..4077e351ba8f9dbf8dc56dddef2eaf0df81e459d 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-08  Eli Zaretskii  <eliz@gnu.org>
+
+       * simple.el (line-move-visual): When converting X pixel coordinate
+       to temporary-goal-column, adjust the value for right-to-left
+       screen lines.  This fixes vertical-motion, next/prev-line, etc.
+
 2015-01-08  Glenn Morris  <rgm@gnu.org>
 
        * files.el (file-tree-walk): Remove; of unknown authorship.  (Bug#19325)
index e15291a345b50c158ec7e577915bd024f9ab9daa..25293edf88fe68e4c941bec7ff9dc6cee86d2370 100644 (file)
@@ -5604,14 +5604,22 @@ If NOERROR, don't signal an error if we can't move that many lines."
                (>  (cdr temporary-goal-column) 0))
            (setq target-hscroll (cdr temporary-goal-column)))
       ;; Otherwise, we should reset `temporary-goal-column'.
-      (let ((posn (posn-at-point)))
+      (let ((posn (posn-at-point))
+           x-pos)
        (cond
         ;; Handle the `overflow-newline-into-fringe' case:
         ((eq (nth 1 posn) 'right-fringe)
          (setq temporary-goal-column (cons (- (window-width) 1) hscroll)))
         ((car (posn-x-y posn))
+         (setq x-pos (car (posn-x-y posn)))
+         ;; In R2L lines, the X pixel coordinate is measured from the
+         ;; left edge of the window, but columns are still counted
+         ;; from the logical-order beginning of the line, i.e. from
+         ;; the right edge in this case.  We need to adjust for that.
+         (if (eq (current-bidi-paragraph-direction) 'right-to-left)
+             (setq x-pos (- (window-body-width nil t) 1 x-pos)))
          (setq temporary-goal-column
-               (cons (/ (float (car (posn-x-y posn)))
+               (cons (/ (float x-pos)
                         (frame-char-width))
                       hscroll))))))
     (if target-hscroll
index 4365222ff7b0368c36285f7412ef3a57a1138830..c302f95d3fa11217300fe39450b5b09b1abd8577 100644 (file)
@@ -1,5 +1,10 @@
 2015-01-08  Eli Zaretskii  <eliz@gnu.org>
 
+       * dispnew.c (buffer_posn_from_coords): Fix the value of the column
+       returned for right-to-left screen lines.  (Before the change on
+       2014-12-30, the incorrectly-computed X pixel coordinate concealed
+       this bug.)
+
        * .gdbinit (xsymname): New subroutine.
        (xprintsym, initial-tbreak): Use it to access the name of a symbol
        in a way that doesn't cause GDB to barf when it tries to
index b998e654881079c36d750a1ffc9a56cb0138a8cf..cefcd0809a0078908451bf91142ec267b41f5261 100644 (file)
@@ -5162,7 +5162,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
 
   Fset_buffer (old_current_buffer);
 
-  *dx = x0 + it.first_visible_x - it.current_x;
+  *dx = to_x - it.current_x;
   *dy = *y - it.current_y;
 
   string = w->contents;
@@ -5237,9 +5237,9 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
     }
 
   /* Add extra (default width) columns if clicked after EOL. */
-  x1 = max (0, it.current_x + it.pixel_width - it.first_visible_x);
-  if (x0 > x1)
-    it.hpos += (x0 - x1) / WINDOW_FRAME_COLUMN_WIDTH (w);
+  x1 = max (0, it.current_x + it.pixel_width);
+  if (to_x > x1)
+    it.hpos += (to_x - x1) / WINDOW_FRAME_COLUMN_WIDTH (w);
 
   *x = it.hpos;
   *y = it.vpos;