Mercurial > emacs
changeset 108824:8aaae2681a62
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>.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 29 May 2010 18:19:13 +0300 |
parents | 99cde7115a1a |
children | fb9ef960b2a5 |
files | doc/emacs/ChangeLog doc/emacs/basic.texi lisp/ChangeLog lisp/bindings.el lisp/subr.el |
diffstat | 5 files changed, 90 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/emacs/ChangeLog Sat May 29 15:51:01 2010 +0300 +++ b/doc/emacs/ChangeLog Sat May 29 18:19:13 2010 +0300 @@ -1,3 +1,8 @@ +2010-05-29 Eli Zaretskii <eliz@gnu.org> + + * basic.texi (Moving Point): Update due to renaming of commands bound + to arrows. Document bidi-aware behavior of C-<right> and C-<left>. + 2010-05-18 Eli Zaretskii <eliz@gnu.org> * display.texi (Fringes): Document reversal of fringe arrows for R2L
--- a/doc/emacs/basic.texi Sat May 29 15:51:01 2010 +0300 +++ b/doc/emacs/basic.texi Sat May 29 18:19:13 2010 +0300 @@ -146,8 +146,8 @@ @findex move-end-of-line @findex forward-char @findex backward-char -@findex right-arrow-command -@findex left-arrow-command +@findex right-char +@findex left-char @findex next-line @findex previous-line @findex beginning-of-buffer @@ -165,7 +165,7 @@ @item C-f Move forward one character (@code{forward-char}). @item @key{right} -Move one character to the right (@code{right-arrow-command}). This +Move one character to the right (@code{right-char}). This moves one character forward in text that is read in the usual left-to-right direction, but one character @emph{backward} if the text is read right-to-left, as needed for right-to-left scripts such as @@ -173,17 +173,23 @@ @item C-b Move backward one character (@code{backward-char}). @item @key{left} -Move one character to the left (@code{left-arrow-command}). This +Move one character to the left (@code{left-char}). This moves one character backward in left-to-right text and one character forward in right-to-left text. @item M-f @itemx M-@key{right} -@itemx C-@key{right} Move forward one word (@code{forward-word}). +@item C-@key{right} +Move one word to the right (@code{right-word}). This moves one word +forward in left-to-right text and one word backward in right-to-left +text. @item M-b @itemx M-@key{left} -@itemx C-@key{left} Move backward one word (@code{backward-word}). +@item C-@key{left} +Move one word to the left (@code{left-word}). This moves one word +backward in left-to-right text and one word forward in right-to-left +text. @item C-n @itemx @key{down} Move down one screen line (@code{next-line}). This command attempts
--- a/lisp/ChangeLog Sat May 29 15:51:01 2010 +0300 +++ b/lisp/ChangeLog Sat May 29 18:19:13 2010 +0300 @@ -1,5 +1,17 @@ 2010-05-29 Eli Zaretskii <eliz@gnu.org> + Bidi-sensitive word movement with arrow keys. + * subr.el (right-arrow-command, left-arrow-command): Move to + bindings.el. + + * 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. + * ls-lisp.el (ls-lisp-classify-file): New function. (ls-lisp-insert-directory): Call it if switches include -F (bug#6294). (ls-lisp-classify): Call ls-lisp-classify-file.
--- a/lisp/bindings.el Sat May 29 15:51:01 2010 +0300 +++ b/lisp/bindings.el Sat May 29 18:19:13 2010 +0300 @@ -678,6 +678,63 @@ ;but they are not assigned to keys there. (put 'narrow-to-region 'disabled t) +;; Moving with arrows in bidi-sensitive direction. +(defun right-char (&optional n) + "Move point N characters to the right (to the left if N is negative). +On reaching beginning or end of buffer, stop and signal error. + +Depending on the bidirectional context, this may move either forward +or backward in the buffer. This is in contrast with \\[forward-char] +and \\[backward-char], which see." + (interactive "^p") + (if (eq (current-bidi-paragraph-direction) 'left-to-right) + (forward-char n) + (backward-char n))) + +(defun left-char ( &optional n) + "Move point N characters to the left (to the right if N is negative). +On reaching beginning or end of buffer, stop and signal error. + +Depending on the bidirectional context, this may move either backward +or forward in the buffer. This is in contrast with \\[backward-char] +and \\[forward-char], which see." + (interactive "^p") + (if (eq (current-bidi-paragraph-direction) 'left-to-right) + (backward-char n) + (forward-char n))) + +(defun right-word (&optional n) + "Move point N words to the right (to the left if N is negative). + +Depending on the bidirectional context, this may move either forward +or backward in the buffer. This is in contrast with \\[forward-word] +and \\[backward-word], which see. + +Value is normally t. +If an edge of the buffer or a field boundary is reached, point is left there +there and the function returns nil. Field boundaries are not noticed +if `inhibit-field-text-motion' is non-nil." + (interactive "^p") + (if (eq (current-bidi-paragraph-direction) 'left-to-right) + (forward-word n) + (backward-word n))) + +(defun left-word (&optional n) + "Move point N words to the left (to the right if N is negative). + +Depending on the bidirectional context, this may move either backward +or forward in the buffer. This is in contrast with \\[backward-word] +and \\[forward-word], which see. + +Value is normally t. +If an edge of the buffer or a field boundary is reached, point is left there +there and the function returns nil. Field boundaries are not noticed +if `inhibit-field-text-motion' is non-nil." + (interactive "^p") + (if (eq (current-bidi-paragraph-direction) 'left-to-right) + (backward-word n) + (forward-word n))) + (defvar narrow-map (make-sparse-keymap) "Keymap for narrowing commands.") (define-key ctl-x-map "n" narrow-map) @@ -828,9 +885,9 @@ (define-key global-map [C-home] 'beginning-of-buffer) (define-key global-map [M-home] 'beginning-of-buffer-other-window) (define-key esc-map [home] 'beginning-of-buffer-other-window) -(define-key global-map [left] 'left-arrow-command) +(define-key global-map [left] 'left-char) (define-key global-map [up] 'previous-line) -(define-key global-map [right] 'right-arrow-command) +(define-key global-map [right] 'right-char) (define-key global-map [down] 'next-line) (define-key global-map [prior] 'scroll-down-command) (define-key global-map [next] 'scroll-up-command) @@ -1030,8 +1087,8 @@ (global-set-key [M-left] 'backward-word) (define-key esc-map [left] 'backward-word) ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors. -(global-set-key [C-right] 'forward-word) -(global-set-key [C-left] 'backward-word) +(global-set-key [C-right] 'right-word) +(global-set-key [C-left] 'left-word) ;; This is not quite compatible, but at least is analogous (global-set-key [C-delete] 'kill-word) (global-set-key [C-backspace] 'backward-kill-word)
--- a/lisp/subr.el Sat May 29 15:51:01 2010 +0300 +++ b/lisp/subr.el Sat May 29 18:19:13 2010 +0300 @@ -3802,30 +3802,5 @@ (prin1-to-string (make-hash-table))))) (provide 'hashtable-print-readable)) -;; Moving with arrows in bidi-sensitive direction. -(defun right-arrow-command (&optional n) - "Move point N characters to the right (to the left if N is negative). -On reaching beginning or end of buffer, stop and signal error. - -Depending on the bidirectional context, this may move either forward -or backward in the buffer. This is in contrast with \\[forward-char] -and \\[backward-char], which see." - (interactive "^p") - (if (eq (current-bidi-paragraph-direction) 'left-to-right) - (forward-char n) - (backward-char n))) - -(defun left-arrow-command ( &optional n) - "Move point N characters to the left (to the right if N is negative). -On reaching beginning or end of buffer, stop and signal error. - -Depending on the bidirectional context, this may move either backward -or forward in the buffer. This is in contrast with \\[backward-char] -and \\[forward-char], which see." - (interactive "^p") - (if (eq (current-bidi-paragraph-direction) 'left-to-right) - (backward-char n) - (forward-char n))) - ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc ;;; subr.el ends here