diff options
| author | Eli Zaretskii | 2015-01-08 16:04:46 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-01-09 11:06:18 +0200 |
| commit | 7c0bfa1d0803d824e3adaf9c6431997580771ef6 (patch) | |
| tree | fda2be0d3c305debeaba26f242830141d4444709 | |
| parent | 2a57b7e5b42175031efb8b4348638a05cb1c52a2 (diff) | |
| download | emacs-7c0bfa1d0803d824e3adaf9c6431997580771ef6.tar.gz emacs-7c0bfa1d0803d824e3adaf9c6431997580771ef6.zip | |
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
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/simple.el | 15 | ||||
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/dispnew.c | 8 |
4 files changed, 29 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 73aa3e023b7..2a6c960c4be 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-01-08 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (line-move-visual): When converting X pixel coordinate | ||
| 4 | to temporary-goal-column, adjust the value for right-to-left | ||
| 5 | screen lines. This fixes vertical-motion, next/prev-line, etc. | ||
| 6 | |||
| 1 | 2015-01-06 Glenn Morris <rgm@gnu.org> | 7 | 2015-01-06 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * progmodes/sh-script.el (sh-mode): Doc fix. | 9 | * progmodes/sh-script.el (sh-mode): Doc fix. |
diff --git a/lisp/simple.el b/lisp/simple.el index 0a1b6336f5f..497e4a1604f 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." | |||
| 5254 | (> (cdr temporary-goal-column) 0)) | 5254 | (> (cdr temporary-goal-column) 0)) |
| 5255 | (setq target-hscroll (cdr temporary-goal-column))) | 5255 | (setq target-hscroll (cdr temporary-goal-column))) |
| 5256 | ;; Otherwise, we should reset `temporary-goal-column'. | 5256 | ;; Otherwise, we should reset `temporary-goal-column'. |
| 5257 | (let ((posn (posn-at-point))) | 5257 | (let ((posn (posn-at-point)) |
| 5258 | x-pos) | ||
| 5258 | (cond | 5259 | (cond |
| 5259 | ;; Handle the `overflow-newline-into-fringe' case: | 5260 | ;; Handle the `overflow-newline-into-fringe' case: |
| 5260 | ((eq (nth 1 posn) 'right-fringe) | 5261 | ((eq (nth 1 posn) 'right-fringe) |
| 5261 | (setq temporary-goal-column (cons (- (window-width) 1) hscroll))) | 5262 | (setq temporary-goal-column (cons (- (window-width) 1) hscroll))) |
| 5262 | ((car (posn-x-y posn)) | 5263 | ((car (posn-x-y posn)) |
| 5264 | (setq x-pos (car (posn-x-y posn))) | ||
| 5265 | ;; In R2L lines, the X pixel coordinate is measured from the | ||
| 5266 | ;; left edge of the window, but columns are still counted | ||
| 5267 | ;; from the logical-order beginning of the line, i.e. from | ||
| 5268 | ;; the right edge in this case. We need to adjust for that. | ||
| 5269 | (if (eq (current-bidi-paragraph-direction) 'right-to-left) | ||
| 5270 | (setq x-pos (- (window-body-width nil t) 1 x-pos))) | ||
| 5263 | (setq temporary-goal-column | 5271 | (setq temporary-goal-column |
| 5264 | (cons (/ (float (car (posn-x-y posn))) | 5272 | (cons (/ (float x-pos) |
| 5265 | (frame-char-width)) hscroll)))))) | 5273 | (frame-char-width)) |
| 5274 | hscroll)))))) | ||
| 5266 | (if target-hscroll | 5275 | (if target-hscroll |
| 5267 | (set-window-hscroll (selected-window) target-hscroll)) | 5276 | (set-window-hscroll (selected-window) target-hscroll)) |
| 5268 | ;; vertical-motion can move more than it was asked to if it moves | 5277 | ;; vertical-motion can move more than it was asked to if it moves |
diff --git a/src/ChangeLog b/src/ChangeLog index acd7e729254..25f3264198d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2015-01-08 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * dispnew.c (buffer_posn_from_coords): Fix the value of the column | ||
| 4 | returned for right-to-left screen lines. (Before the change on | ||
| 5 | 2014-12-30, the incorrectly-computed X pixel coordinate concealed | ||
| 6 | this bug.) | ||
| 7 | |||
| 1 | 2015-01-05 Eli Zaretskii <eliz@gnu.org> | 8 | 2015-01-05 Eli Zaretskii <eliz@gnu.org> |
| 2 | 9 | ||
| 3 | * xdisp.c (move_it_to, try_cursor_movement): Don't use the window | 10 | * xdisp.c (move_it_to, try_cursor_movement): Don't use the window |
diff --git a/src/dispnew.c b/src/dispnew.c index 205c28f7df8..f73ea58b7f3 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 | |||
| 5153 | 5153 | ||
| 5154 | Fset_buffer (old_current_buffer); | 5154 | Fset_buffer (old_current_buffer); |
| 5155 | 5155 | ||
| 5156 | *dx = x0 + it.first_visible_x - it.current_x; | 5156 | *dx = to_x - it.current_x; |
| 5157 | *dy = *y - it.current_y; | 5157 | *dy = *y - it.current_y; |
| 5158 | 5158 | ||
| 5159 | string = w->contents; | 5159 | string = w->contents; |
| @@ -5228,9 +5228,9 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p | |||
| 5228 | } | 5228 | } |
| 5229 | 5229 | ||
| 5230 | /* Add extra (default width) columns if clicked after EOL. */ | 5230 | /* Add extra (default width) columns if clicked after EOL. */ |
| 5231 | x1 = max (0, it.current_x + it.pixel_width - it.first_visible_x); | 5231 | x1 = max (0, it.current_x + it.pixel_width); |
| 5232 | if (x0 > x1) | 5232 | if (to_x > x1) |
| 5233 | it.hpos += (x0 - x1) / WINDOW_FRAME_COLUMN_WIDTH (w); | 5233 | it.hpos += (to_x - x1) / WINDOW_FRAME_COLUMN_WIDTH (w); |
| 5234 | 5234 | ||
| 5235 | *x = it.hpos; | 5235 | *x = it.hpos; |
| 5236 | *y = it.vpos; | 5236 | *y = it.vpos; |