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 /lisp | |
| 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>.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/bindings.el | 65 | ||||
| -rw-r--r-- | lisp/subr.el | 25 |
3 files changed, 73 insertions, 29 deletions
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 |