diff options
| author | Eli Zaretskii | 2010-05-29 18:19:13 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-05-29 18:19:13 +0300 |
| commit | db5dce9dd18461205d9320bb705648fe44df328b (patch) | |
| tree | 2513c57935d0c244d00af98febe702e41b40ab23 | |
| parent | 06fa4a23522821fc3a4e93c7ca505bae4d4733de (diff) | |
| download | emacs-db5dce9dd18461205d9320bb705648fe44df328b.tar.gz emacs-db5dce9dd18461205d9320bb705648fe44df328b.zip | |
Implement bidi-sensitive word movement with arrow keys.
lisp/subr.el (right-arrow-command, left-arrow-command): Move to bindings.el.
lisp/bindings.el (right-char, left-char): Move from subr.el and
rename from right-arrow-command and left-arrow-command.
(right-word, left-word): New functions.
(global-map) <right>: Bind to right-char.
(global-map) <left>: Bind to left-char.
(global-map) <C-right>: Bind to right-word.
(global-map) <C-left>: Bind to left-word.
doc/emacs/basic.texi (Moving Point): Update due to renaming of commands bound
to arrows. Document bidi-aware behavior of C-<right> and C-<left>.
| -rw-r--r-- | doc/emacs/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/emacs/basic.texi | 18 | ||||
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/bindings.el | 65 | ||||
| -rw-r--r-- | lisp/subr.el | 25 |
5 files changed, 90 insertions, 35 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 82d4d028040..e43b4466d1f 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-05-29 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * basic.texi (Moving Point): Update due to renaming of commands bound | ||
| 4 | to arrows. Document bidi-aware behavior of C-<right> and C-<left>. | ||
| 5 | |||
| 1 | 2010-05-18 Eli Zaretskii <eliz@gnu.org> | 6 | 2010-05-18 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * display.texi (Fringes): Document reversal of fringe arrows for R2L | 8 | * display.texi (Fringes): Document reversal of fringe arrows for R2L |
diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi index 654c017c59e..27ca4593339 100644 --- a/doc/emacs/basic.texi +++ b/doc/emacs/basic.texi | |||
| @@ -146,8 +146,8 @@ keyboard commands that move point in more sophisticated ways. | |||
| 146 | @findex move-end-of-line | 146 | @findex move-end-of-line |
| 147 | @findex forward-char | 147 | @findex forward-char |
| 148 | @findex backward-char | 148 | @findex backward-char |
| 149 | @findex right-arrow-command | 149 | @findex right-char |
| 150 | @findex left-arrow-command | 150 | @findex left-char |
| 151 | @findex next-line | 151 | @findex next-line |
| 152 | @findex previous-line | 152 | @findex previous-line |
| 153 | @findex beginning-of-buffer | 153 | @findex beginning-of-buffer |
| @@ -165,7 +165,7 @@ Move to the end of the line (@code{move-end-of-line}). | |||
| 165 | @item C-f | 165 | @item C-f |
| 166 | Move forward one character (@code{forward-char}). | 166 | Move forward one character (@code{forward-char}). |
| 167 | @item @key{right} | 167 | @item @key{right} |
| 168 | Move one character to the right (@code{right-arrow-command}). This | 168 | Move one character to the right (@code{right-char}). This |
| 169 | moves one character forward in text that is read in the usual | 169 | moves one character forward in text that is read in the usual |
| 170 | left-to-right direction, but one character @emph{backward} if the text | 170 | left-to-right direction, but one character @emph{backward} if the text |
| 171 | is read right-to-left, as needed for right-to-left scripts such as | 171 | is read right-to-left, as needed for right-to-left scripts such as |
| @@ -173,17 +173,23 @@ Arabic. @xref{Bidirectional Editing}. | |||
| 173 | @item C-b | 173 | @item C-b |
| 174 | Move backward one character (@code{backward-char}). | 174 | Move backward one character (@code{backward-char}). |
| 175 | @item @key{left} | 175 | @item @key{left} |
| 176 | Move one character to the left (@code{left-arrow-command}). This | 176 | Move one character to the left (@code{left-char}). This |
| 177 | moves one character backward in left-to-right text and one character | 177 | moves one character backward in left-to-right text and one character |
| 178 | forward in right-to-left text. | 178 | forward in right-to-left text. |
| 179 | @item M-f | 179 | @item M-f |
| 180 | @itemx M-@key{right} | 180 | @itemx M-@key{right} |
| 181 | @itemx C-@key{right} | ||
| 182 | Move forward one word (@code{forward-word}). | 181 | Move forward one word (@code{forward-word}). |
| 182 | @item C-@key{right} | ||
| 183 | Move one word to the right (@code{right-word}). This moves one word | ||
| 184 | forward in left-to-right text and one word backward in right-to-left | ||
| 185 | text. | ||
| 183 | @item M-b | 186 | @item M-b |
| 184 | @itemx M-@key{left} | 187 | @itemx M-@key{left} |
| 185 | @itemx C-@key{left} | ||
| 186 | Move backward one word (@code{backward-word}). | 188 | Move backward one word (@code{backward-word}). |
| 189 | @item C-@key{left} | ||
| 190 | Move one word to the left (@code{left-word}). This moves one word | ||
| 191 | backward in left-to-right text and one word forward in right-to-left | ||
| 192 | text. | ||
| 187 | @item C-n | 193 | @item C-n |
| 188 | @itemx @key{down} | 194 | @itemx @key{down} |
| 189 | Move down one screen line (@code{next-line}). This command attempts | 195 | Move down one screen line (@code{next-line}). This command attempts |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f56d29196f6..d16067c5378 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2010-05-29 Eli Zaretskii <eliz@gnu.org> | 1 | 2010-05-29 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | Bidi-sensitive word movement with arrow keys. | ||
| 4 | * subr.el (right-arrow-command, left-arrow-command): Move to | ||
| 5 | bindings.el. | ||
| 6 | |||
| 7 | * bindings.el (right-char, left-char): Move from subr.el and | ||
| 8 | rename from right-arrow-command and left-arrow-command. | ||
| 9 | (right-word, left-word): New functions. | ||
| 10 | (global-map) <right>: Bind to right-char. | ||
| 11 | (global-map) <left>: Bind to left-char. | ||
| 12 | (global-map) <C-right>: Bind to right-word. | ||
| 13 | (global-map) <C-left>: Bind to left-word. | ||
| 14 | |||
| 3 | * ls-lisp.el (ls-lisp-classify-file): New function. | 15 | * ls-lisp.el (ls-lisp-classify-file): New function. |
| 4 | (ls-lisp-insert-directory): Call it if switches include -F (bug#6294). | 16 | (ls-lisp-insert-directory): Call it if switches include -F (bug#6294). |
| 5 | (ls-lisp-classify): Call ls-lisp-classify-file. | 17 | (ls-lisp-classify): Call ls-lisp-classify-file. |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 14cebfeda8f..f9d3e75cf6e 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -678,6 +678,63 @@ is okay. See `mode-line-format'.") | |||
| 678 | ;but they are not assigned to keys there. | 678 | ;but they are not assigned to keys there. |
| 679 | (put 'narrow-to-region 'disabled t) | 679 | (put 'narrow-to-region 'disabled t) |
| 680 | 680 | ||
| 681 | ;; Moving with arrows in bidi-sensitive direction. | ||
| 682 | (defun right-char (&optional n) | ||
| 683 | "Move point N characters to the right (to the left if N is negative). | ||
| 684 | On reaching beginning or end of buffer, stop and signal error. | ||
| 685 | |||
| 686 | Depending on the bidirectional context, this may move either forward | ||
| 687 | or backward in the buffer. This is in contrast with \\[forward-char] | ||
| 688 | and \\[backward-char], which see." | ||
| 689 | (interactive "^p") | ||
| 690 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 691 | (forward-char n) | ||
| 692 | (backward-char n))) | ||
| 693 | |||
| 694 | (defun left-char ( &optional n) | ||
| 695 | "Move point N characters to the left (to the right if N is negative). | ||
| 696 | On reaching beginning or end of buffer, stop and signal error. | ||
| 697 | |||
| 698 | Depending on the bidirectional context, this may move either backward | ||
| 699 | or forward in the buffer. This is in contrast with \\[backward-char] | ||
| 700 | and \\[forward-char], which see." | ||
| 701 | (interactive "^p") | ||
| 702 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 703 | (backward-char n) | ||
| 704 | (forward-char n))) | ||
| 705 | |||
| 706 | (defun right-word (&optional n) | ||
| 707 | "Move point N words to the right (to the left if N is negative). | ||
| 708 | |||
| 709 | Depending on the bidirectional context, this may move either forward | ||
| 710 | or backward in the buffer. This is in contrast with \\[forward-word] | ||
| 711 | and \\[backward-word], which see. | ||
| 712 | |||
| 713 | Value is normally t. | ||
| 714 | If an edge of the buffer or a field boundary is reached, point is left there | ||
| 715 | there and the function returns nil. Field boundaries are not noticed | ||
| 716 | if `inhibit-field-text-motion' is non-nil." | ||
| 717 | (interactive "^p") | ||
| 718 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 719 | (forward-word n) | ||
| 720 | (backward-word n))) | ||
| 721 | |||
| 722 | (defun left-word (&optional n) | ||
| 723 | "Move point N words to the left (to the right if N is negative). | ||
| 724 | |||
| 725 | Depending on the bidirectional context, this may move either backward | ||
| 726 | or forward in the buffer. This is in contrast with \\[backward-word] | ||
| 727 | and \\[forward-word], which see. | ||
| 728 | |||
| 729 | Value is normally t. | ||
| 730 | If an edge of the buffer or a field boundary is reached, point is left there | ||
| 731 | there and the function returns nil. Field boundaries are not noticed | ||
| 732 | if `inhibit-field-text-motion' is non-nil." | ||
| 733 | (interactive "^p") | ||
| 734 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 735 | (backward-word n) | ||
| 736 | (forward-word n))) | ||
| 737 | |||
| 681 | (defvar narrow-map (make-sparse-keymap) | 738 | (defvar narrow-map (make-sparse-keymap) |
| 682 | "Keymap for narrowing commands.") | 739 | "Keymap for narrowing commands.") |
| 683 | (define-key ctl-x-map "n" narrow-map) | 740 | (define-key ctl-x-map "n" narrow-map) |
| @@ -828,9 +885,9 @@ is okay. See `mode-line-format'.") | |||
| 828 | (define-key global-map [C-home] 'beginning-of-buffer) | 885 | (define-key global-map [C-home] 'beginning-of-buffer) |
| 829 | (define-key global-map [M-home] 'beginning-of-buffer-other-window) | 886 | (define-key global-map [M-home] 'beginning-of-buffer-other-window) |
| 830 | (define-key esc-map [home] 'beginning-of-buffer-other-window) | 887 | (define-key esc-map [home] 'beginning-of-buffer-other-window) |
| 831 | (define-key global-map [left] 'left-arrow-command) | 888 | (define-key global-map [left] 'left-char) |
| 832 | (define-key global-map [up] 'previous-line) | 889 | (define-key global-map [up] 'previous-line) |
| 833 | (define-key global-map [right] 'right-arrow-command) | 890 | (define-key global-map [right] 'right-char) |
| 834 | (define-key global-map [down] 'next-line) | 891 | (define-key global-map [down] 'next-line) |
| 835 | (define-key global-map [prior] 'scroll-down-command) | 892 | (define-key global-map [prior] 'scroll-down-command) |
| 836 | (define-key global-map [next] 'scroll-up-command) | 893 | (define-key global-map [next] 'scroll-up-command) |
| @@ -1030,8 +1087,8 @@ is okay. See `mode-line-format'.") | |||
| 1030 | (global-set-key [M-left] 'backward-word) | 1087 | (global-set-key [M-left] 'backward-word) |
| 1031 | (define-key esc-map [left] 'backward-word) | 1088 | (define-key esc-map [left] 'backward-word) |
| 1032 | ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors. | 1089 | ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors. |
| 1033 | (global-set-key [C-right] 'forward-word) | 1090 | (global-set-key [C-right] 'right-word) |
| 1034 | (global-set-key [C-left] 'backward-word) | 1091 | (global-set-key [C-left] 'left-word) |
| 1035 | ;; This is not quite compatible, but at least is analogous | 1092 | ;; This is not quite compatible, but at least is analogous |
| 1036 | (global-set-key [C-delete] 'kill-word) | 1093 | (global-set-key [C-delete] 'kill-word) |
| 1037 | (global-set-key [C-backspace] 'backward-kill-word) | 1094 | (global-set-key [C-backspace] 'backward-kill-word) |
diff --git a/lisp/subr.el b/lisp/subr.el index fb84f95c805..beb6672a7e1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3802,30 +3802,5 @@ which is higher than \"1alpha\"." | |||
| 3802 | (prin1-to-string (make-hash-table))))) | 3802 | (prin1-to-string (make-hash-table))))) |
| 3803 | (provide 'hashtable-print-readable)) | 3803 | (provide 'hashtable-print-readable)) |
| 3804 | 3804 | ||
| 3805 | ;; Moving with arrows in bidi-sensitive direction. | ||
| 3806 | (defun right-arrow-command (&optional n) | ||
| 3807 | "Move point N characters to the right (to the left if N is negative). | ||
| 3808 | On reaching beginning or end of buffer, stop and signal error. | ||
| 3809 | |||
| 3810 | Depending on the bidirectional context, this may move either forward | ||
| 3811 | or backward in the buffer. This is in contrast with \\[forward-char] | ||
| 3812 | and \\[backward-char], which see." | ||
| 3813 | (interactive "^p") | ||
| 3814 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 3815 | (forward-char n) | ||
| 3816 | (backward-char n))) | ||
| 3817 | |||
| 3818 | (defun left-arrow-command ( &optional n) | ||
| 3819 | "Move point N characters to the left (to the right if N is negative). | ||
| 3820 | On reaching beginning or end of buffer, stop and signal error. | ||
| 3821 | |||
| 3822 | Depending on the bidirectional context, this may move either backward | ||
| 3823 | or forward in the buffer. This is in contrast with \\[backward-char] | ||
| 3824 | and \\[forward-char], which see." | ||
| 3825 | (interactive "^p") | ||
| 3826 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 3827 | (backward-char n) | ||
| 3828 | (forward-char n))) | ||
| 3829 | |||
| 3830 | ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc | 3805 | ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc |
| 3831 | ;;; subr.el ends here | 3806 | ;;; subr.el ends here |