mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-22 07:09:54 +00:00
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>.
This commit is contained in:
parent
06fa4a2352
commit
db5dce9dd1
@ -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
|
||||
|
@ -146,8 +146,8 @@ keyboard commands that move point in more sophisticated ways.
|
||||
@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 @@ Move to the end of the line (@code{move-end-of-line}).
|
||||
@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 @@ Arabic. @xref{Bidirectional Editing}.
|
||||
@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
|
||||
|
@ -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.
|
||||
|
@ -678,6 +678,63 @@ is okay. See `mode-line-format'.")
|
||||
;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 @@ is okay. See `mode-line-format'.")
|
||||
(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 @@ is okay. See `mode-line-format'.")
|
||||
(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)
|
||||
|
25
lisp/subr.el
25
lisp/subr.el
@ -3802,30 +3802,5 @@ which is higher than \"1alpha\"."
|
||||
(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
|
||||
|
Loading…
Reference in New Issue
Block a user