emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 7c0bfa1: Fix line-move-visual's following of colu


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 7c0bfa1: Fix line-move-visual's following of column in R2L lines (backport from trunk).
Date: Fri, 09 Jan 2015 09:06:50 +0000

branch: emacs-24
commit 7c0bfa1d0803d824e3adaf9c6431997580771ef6
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix line-move-visual's following of column in R2L lines (backport from 
trunk).
    
     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.)
    
    (cherry picked from commit 5fbd17e369ca30a47ab8a2eda0b2f2ea9b690bb4)
    
    Conflicts:
        lisp/simple.el
---
 lisp/ChangeLog |    6 ++++++
 lisp/simple.el |   15 ++++++++++++---
 src/ChangeLog  |    7 +++++++
 src/dispnew.c  |    8 ++++----
 4 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 73aa3e0..2a6c960 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-08  Eli Zaretskii  <address@hidden>
+
+       * 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-06  Glenn Morris  <address@hidden>
 
        * progmodes/sh-script.el (sh-mode): Doc fix.
diff --git a/lisp/simple.el b/lisp/simple.el
index 0a1b633..497e4a16 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5254,15 +5254,24 @@ 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)))
-                        (frame-char-width)) hscroll))))))
+               (cons (/ (float x-pos)
+                        (frame-char-width))
+                      hscroll))))))
     (if target-hscroll
        (set-window-hscroll (selected-window) target-hscroll))
     ;; vertical-motion can move more than it was asked to if it moves
diff --git a/src/ChangeLog b/src/ChangeLog
index acd7e72..25f3264 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-08  Eli Zaretskii  <address@hidden>
+
+       * 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.)
+
 2015-01-05  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (move_it_to, try_cursor_movement): Don't use the window
diff --git a/src/dispnew.c b/src/dispnew.c
index 205c28f..f73ea58 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5153,7 +5153,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;
@@ -5228,9 +5228,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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]