diff options
| author | Eli Zaretskii | 2013-06-29 16:36:19 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-06-29 16:36:19 +0300 |
| commit | 4c672a0fec1d18cc1a445acf3e6935d681d4048f (patch) | |
| tree | c8fb2626c93a226bed5eaa0b92f95925734e893f /lisp | |
| parent | 73b1b3ad6196234984a29298bc66eabf1299de66 (diff) | |
| download | emacs-4c672a0fec1d18cc1a445acf3e6935d681d4048f.tar.gz emacs-4c672a0fec1d18cc1a445acf3e6935d681d4048f.zip | |
Implement visual-order cursor motion.
src/xdisp.c (Fmove_point_visually): New function.
lisp/bindings.el (visual-order-cursor-movement): New defcustom.
(right-char, left-char): Provide visual-order cursor motion by
calling move-point-visually. Update the doc strings.
doc/emacs/basic.texi (Moving Point): Document visual-order-cursor-movement
and its effect on right-char and left-char.
doc/lispref/display.texi (Bidirectional Display): Document move-point-visually.
etc/NEWS: Document the new feature.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/bindings.el | 58 |
2 files changed, 52 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 826f270d8f8..1e1fff6fc25 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-06-29 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * bindings.el (visual-order-cursor-movement): New defcustom. | ||
| 4 | (right-char, left-char): Provide visual-order cursor motion by | ||
| 5 | calling move-point-visually. Update the doc strings. | ||
| 6 | |||
| 1 | 2013-06-28 Kenichi Handa <handa@gnu.org> | 7 | 2013-06-28 Kenichi Handa <handa@gnu.org> |
| 2 | 8 | ||
| 3 | * international/mule.el (define-coding-system): New coding system | 9 | * international/mule.el (define-coding-system): New coding system |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 2013c079820..7c42cc6c0a8 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -696,29 +696,63 @@ language you are using." | |||
| 696 | (put 'narrow-to-region 'disabled t) | 696 | (put 'narrow-to-region 'disabled t) |
| 697 | 697 | ||
| 698 | ;; Moving with arrows in bidi-sensitive direction. | 698 | ;; Moving with arrows in bidi-sensitive direction. |
| 699 | (defcustom visual-order-cursor-movement nil | ||
| 700 | "If non-nil, moving cursor with arrow keys follows the visual order. | ||
| 701 | |||
| 702 | When this is non-nil, \\[right-char] will move to the character that is | ||
| 703 | to the right of point on display, and \\[left-char] will move to the left, | ||
| 704 | disregarding the surrounding bidirectional context. Depending on the | ||
| 705 | bidirectional context of the surrounding characters, this can move point | ||
| 706 | many buffer positions away. | ||
| 707 | |||
| 708 | When the text is entirely left-to-right, logical-order and visual-order | ||
| 709 | cursor movements produce identical results." | ||
| 710 | :type '(choice (const :tag "Logical-order cursor movement" nil) | ||
| 711 | (const :tag "Visual-order cursor movement" t)) | ||
| 712 | :group 'display | ||
| 713 | :version "24.5") | ||
| 714 | |||
| 699 | (defun right-char (&optional n) | 715 | (defun right-char (&optional n) |
| 700 | "Move point N characters to the right (to the left if N is negative). | 716 | "Move point N characters to the right (to the left if N is negative). |
| 701 | On reaching beginning or end of buffer, stop and signal error. | 717 | On reaching beginning or end of buffer, stop and signal error. |
| 702 | 718 | ||
| 703 | Depending on the bidirectional context, this may move either forward | 719 | If `visual-order-cursor-movement' is non-nil, this always moves |
| 704 | or backward in the buffer. This is in contrast with \\[forward-char] | 720 | to the right on display, wherever that is in the buffer. |
| 705 | and \\[backward-char], which see." | 721 | Otherwise, depending on the bidirectional context, this may move |
| 722 | one position either forward or backward in the buffer. This is | ||
| 723 | in contrast with \\[forward-char] and \\[backward-char], which | ||
| 724 | see." | ||
| 706 | (interactive "^p") | 725 | (interactive "^p") |
| 707 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | 726 | (if visual-order-cursor-movement |
| 708 | (forward-char n) | 727 | (dotimes (i (if (numberp n) (abs n) 1)) |
| 709 | (backward-char n))) | 728 | (if (< n 0) |
| 729 | (move-point-visually -1) | ||
| 730 | (move-point-visually 1)) | ||
| 731 | (sit-for 0)) | ||
| 732 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 733 | (forward-char n) | ||
| 734 | (backward-char n)))) | ||
| 710 | 735 | ||
| 711 | (defun left-char ( &optional n) | 736 | (defun left-char ( &optional n) |
| 712 | "Move point N characters to the left (to the right if N is negative). | 737 | "Move point N characters to the left (to the right if N is negative). |
| 713 | On reaching beginning or end of buffer, stop and signal error. | 738 | On reaching beginning or end of buffer, stop and signal error. |
| 714 | 739 | ||
| 715 | Depending on the bidirectional context, this may move either backward | 740 | If `visual-order-cursor-movement' is non-nil, this always moves |
| 716 | or forward in the buffer. This is in contrast with \\[backward-char] | 741 | to the left on display, wherever that is in the buffer. |
| 717 | and \\[forward-char], which see." | 742 | Otherwise, depending on the bidirectional context, this may move |
| 743 | one position either backward or forward in the buffer. This is | ||
| 744 | in contrast with \\[forward-char] and \\[backward-char], which | ||
| 745 | see." | ||
| 718 | (interactive "^p") | 746 | (interactive "^p") |
| 719 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | 747 | (if visual-order-cursor-movement |
| 720 | (backward-char n) | 748 | (dotimes (i (if (numberp n) (abs n) 1)) |
| 721 | (forward-char n))) | 749 | (if (< n 0) |
| 750 | (move-point-visually 1) | ||
| 751 | (move-point-visually -1)) | ||
| 752 | (sit-for 0)) | ||
| 753 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 754 | (backward-char n) | ||
| 755 | (forward-char n)))) | ||
| 722 | 756 | ||
| 723 | (defun right-word (&optional n) | 757 | (defun right-word (&optional n) |
| 724 | "Move point N words to the right (to the left if N is negative). | 758 | "Move point N words to the right (to the left if N is negative). |