Commit db5dce9d authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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>.
parent 06fa4a23
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> 2010-05-18 Eli Zaretskii <eliz@gnu.org>
* display.texi (Fringes): Document reversal of fringe arrows for R2L * display.texi (Fringes): Document reversal of fringe arrows for R2L
......
...@@ -146,8 +146,8 @@ keyboard commands that move point in more sophisticated ways. ...@@ -146,8 +146,8 @@ keyboard commands that move point in more sophisticated ways.
@findex move-end-of-line @findex move-end-of-line
@findex forward-char @findex forward-char
@findex backward-char @findex backward-char
@findex right-arrow-command @findex right-char
@findex left-arrow-command @findex left-char
@findex next-line @findex next-line
@findex previous-line @findex previous-line
@findex beginning-of-buffer @findex beginning-of-buffer
...@@ -165,7 +165,7 @@ Move to the end of the line (@code{move-end-of-line}). ...@@ -165,7 +165,7 @@ Move to the end of the line (@code{move-end-of-line}).
@item C-f @item C-f
Move forward one character (@code{forward-char}). Move forward one character (@code{forward-char}).
@item @key{right} @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 moves one character forward in text that is read in the usual
left-to-right direction, but one character @emph{backward} if the text 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 is read right-to-left, as needed for right-to-left scripts such as
...@@ -173,17 +173,23 @@ Arabic. @xref{Bidirectional Editing}. ...@@ -173,17 +173,23 @@ Arabic. @xref{Bidirectional Editing}.
@item C-b @item C-b
Move backward one character (@code{backward-char}). Move backward one character (@code{backward-char}).
@item @key{left} @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 moves one character backward in left-to-right text and one character
forward in right-to-left text. forward in right-to-left text.
@item M-f @item M-f
@itemx M-@key{right} @itemx M-@key{right}
@itemx C-@key{right}
Move forward one word (@code{forward-word}). 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 @item M-b
@itemx M-@key{left} @itemx M-@key{left}
@itemx C-@key{left}
Move backward one word (@code{backward-word}). 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 @item C-n
@itemx @key{down} @itemx @key{down}
Move down one screen line (@code{next-line}). This command attempts Move down one screen line (@code{next-line}). This command attempts
......
2010-05-29 Eli Zaretskii <eliz@gnu.org> 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.el (ls-lisp-classify-file): New function.
(ls-lisp-insert-directory): Call it if switches include -F (bug#6294). (ls-lisp-insert-directory): Call it if switches include -F (bug#6294).
(ls-lisp-classify): Call ls-lisp-classify-file. (ls-lisp-classify): Call ls-lisp-classify-file.
......
...@@ -678,6 +678,63 @@ is okay. See `mode-line-format'.") ...@@ -678,6 +678,63 @@ is okay. See `mode-line-format'.")
;but they are not assigned to keys there. ;but they are not assigned to keys there.
(put 'narrow-to-region 'disabled t) (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) (defvar narrow-map (make-sparse-keymap)
"Keymap for narrowing commands.") "Keymap for narrowing commands.")
(define-key ctl-x-map "n" narrow-map) (define-key ctl-x-map "n" narrow-map)
...@@ -828,9 +885,9 @@ is okay. See `mode-line-format'.") ...@@ -828,9 +885,9 @@ is okay. See `mode-line-format'.")
(define-key global-map [C-home] 'beginning-of-buffer) (define-key global-map [C-home] 'beginning-of-buffer)
(define-key global-map [M-home] 'beginning-of-buffer-other-window) (define-key global-map [M-home] 'beginning-of-buffer-other-window)
(define-key esc-map [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 [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 [down] 'next-line)
(define-key global-map [prior] 'scroll-down-command) (define-key global-map [prior] 'scroll-down-command)
(define-key global-map [next] 'scroll-up-command) (define-key global-map [next] 'scroll-up-command)
...@@ -1030,8 +1087,8 @@ is okay. See `mode-line-format'.") ...@@ -1030,8 +1087,8 @@ is okay. See `mode-line-format'.")
(global-set-key [M-left] 'backward-word) (global-set-key [M-left] 'backward-word)
(define-key esc-map [left] 'backward-word) (define-key esc-map [left] 'backward-word)
;; ilya@math.ohio-state.edu says these bindings are standard on PC editors. ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
(global-set-key [C-right] 'forward-word) (global-set-key [C-right] 'right-word)
(global-set-key [C-left] 'backward-word) (global-set-key [C-left] 'left-word)
;; This is not quite compatible, but at least is analogous ;; This is not quite compatible, but at least is analogous
(global-set-key [C-delete] 'kill-word) (global-set-key [C-delete] 'kill-word)
(global-set-key [C-backspace] 'backward-kill-word) (global-set-key [C-backspace] 'backward-kill-word)
......
...@@ -3802,30 +3802,5 @@ which is higher than \"1alpha\"." ...@@ -3802,30 +3802,5 @@ which is higher than \"1alpha\"."
(prin1-to-string (make-hash-table))))) (prin1-to-string (make-hash-table)))))
(provide 'hashtable-print-readable)) (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 ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc
;;; subr.el ends here ;;; subr.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment