aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii2013-06-29 16:36:19 +0300
committerEli Zaretskii2013-06-29 16:36:19 +0300
commit4c672a0fec1d18cc1a445acf3e6935d681d4048f (patch)
treec8fb2626c93a226bed5eaa0b92f95925734e893f /lisp
parent73b1b3ad6196234984a29298bc66eabf1299de66 (diff)
downloademacs-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/ChangeLog6
-rw-r--r--lisp/bindings.el58
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 @@
12013-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
12013-06-28 Kenichi Handa <handa@gnu.org> 72013-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
702When this is non-nil, \\[right-char] will move to the character that is
703to the right of point on display, and \\[left-char] will move to the left,
704disregarding the surrounding bidirectional context. Depending on the
705bidirectional context of the surrounding characters, this can move point
706many buffer positions away.
707
708When the text is entirely left-to-right, logical-order and visual-order
709cursor 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).
701On reaching beginning or end of buffer, stop and signal error. 717On reaching beginning or end of buffer, stop and signal error.
702 718
703Depending on the bidirectional context, this may move either forward 719If `visual-order-cursor-movement' is non-nil, this always moves
704or backward in the buffer. This is in contrast with \\[forward-char] 720to the right on display, wherever that is in the buffer.
705and \\[backward-char], which see." 721Otherwise, depending on the bidirectional context, this may move
722one position either forward or backward in the buffer. This is
723in contrast with \\[forward-char] and \\[backward-char], which
724see."
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).
713On reaching beginning or end of buffer, stop and signal error. 738On reaching beginning or end of buffer, stop and signal error.
714 739
715Depending on the bidirectional context, this may move either backward 740If `visual-order-cursor-movement' is non-nil, this always moves
716or forward in the buffer. This is in contrast with \\[backward-char] 741to the left on display, wherever that is in the buffer.
717and \\[forward-char], which see." 742Otherwise, depending on the bidirectional context, this may move
743one position either backward or forward in the buffer. This is
744in contrast with \\[forward-char] and \\[backward-char], which
745see."
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).