X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/9a93067632c0fc183ad5fb4ef44edc4ea8373716..cd8edbbe673d636e262fa499cfee913b640d2e1c:/lisp/bindings.el diff --git a/lisp/bindings.el b/lisp/bindings.el index 7ca1bf4719..2ea6713216 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1,7 +1,7 @@ ;;; bindings.el --- define standard key bindings and some variables -;; Copyright (C) 1985-1987, 1992-1996, 1999-2012 -;; Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1992-1996, 1999-2013 Free Software +;; Foundation, Inc. ;; Maintainer: FSF ;; Keywords: internal @@ -38,23 +38,20 @@ corresponding to the mode line clicked." (defun mode-line-toggle-read-only (event) "Like `toggle-read-only', for the mode-line." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (read-only-mode 'toggle))) (defun mode-line-toggle-modified (event) "Toggle the buffer-modified flag from the mode-line." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (set-buffer-modified-p (not (buffer-modified-p))) (force-mode-line-update))) (defun mode-line-widen (event) "Widen a buffer from the mode-line." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (widen) (force-mode-line-update))) @@ -63,17 +60,13 @@ corresponding to the mode line clicked." (define-key map [mode-line mouse-2] (lambda (e) (interactive "e") - (save-selected-window - (select-window - (posn-window (event-start e))) + (with-selected-window (posn-window (event-start e)) (toggle-input-method) (force-mode-line-update)))) (define-key map [mode-line mouse-3] (lambda (e) (interactive "e") - (save-selected-window - (select-window - (posn-window (event-start e))) + (with-selected-window (posn-window (event-start e)) (describe-current-input-method)))) (purecopy map))) @@ -82,16 +75,14 @@ corresponding to the mode line clicked." (define-key map [mode-line mouse-1] (lambda (e) (interactive "e") - (save-selected-window - (select-window (posn-window (event-start e))) + (with-selected-window (posn-window (event-start e)) (when (and enable-multibyte-characters buffer-file-coding-system) (describe-coding-system buffer-file-coding-system))))) (define-key map [mode-line mouse-3] (lambda (e) (interactive "e") - (save-selected-window - (select-window (posn-window (event-start e))) + (with-selected-window (posn-window (event-start e)) (call-interactively 'set-buffer-file-coding-system)))) (purecopy map)) "Local keymap for the coding-system part of the mode line.") @@ -237,8 +228,7 @@ mnemonics of the following coding systems: 'mouse-face 'mode-line-highlight 'help-echo (purecopy (lambda (window _object _point) (format "%s" - (save-selected-window - (select-window window) + (with-selected-window window (concat (if (file-remote-p default-directory) "Current directory is remote: " @@ -474,15 +464,13 @@ By default, this shows the information specified by (defun mode-line-unbury-buffer (event) "\ Call `unbury-buffer' in this window." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (unbury-buffer))) (defun mode-line-bury-buffer (event) "\ Like `bury-buffer', but temporarily select EVENT's window." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (bury-buffer))) (defun mode-line-other-buffer () "\ @@ -493,15 +481,13 @@ Switch to the most recently selected buffer other than the current one." (defun mode-line-next-buffer (event) "Like `next-buffer', but temporarily select EVENT's window." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (next-buffer))) (defun mode-line-previous-buffer (event) "Like `previous-buffer', but temporarily select EVENT's window." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (previous-buffer))) (defmacro bound-and-true-p (var) @@ -689,7 +675,7 @@ language you are using." (garbage-collect) -(setq help-event-list '(help f1)) +(setq help-event-list '(help f1 ?\?)) (make-variable-buffer-local 'minor-mode-overriding-map-alist) @@ -710,29 +696,57 @@ language you are using." (put 'narrow-to-region 'disabled t) ;; Moving with arrows in bidi-sensitive direction. +(defcustom visual-order-cursor-movement nil + "If non-nil, moving cursor with arrow keys follows the visual order. + +When this is non-nil, \\[right-char] will move to the character that is +to the right of point on display, and \\[left-char] will move to the left, +disregarding the surrounding bidirectional context. Depending on the +bidirectional context of the surrounding characters, this can move point +many buffer positions away. + +When the text is entirely left-to-right, logical-order and visual-order +cursor movements produce identical results." + :type '(choice (const :tag "Logical-order cursor movement" nil) + (const :tag "Visual-order cursor movement" t)) + :group 'display + :version "24.5") + (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." +If `visual-order-cursor-movement' is non-nil, this always moves +to the right on display, wherever that is in the buffer. +Otherwise, depending on the bidirectional context, this may move +one position 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))) + (if visual-order-cursor-movement + (dotimes (i (if (numberp n) (abs n) 1)) + (move-point-visually (if (and (numberp n) (< n 0)) -1 1))) + (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." +If `visual-order-cursor-movement' is non-nil, this always moves +to the left on display, wherever that is in the buffer. +Otherwise, depending on the bidirectional context, this may move +one position either backward or forward 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) - (backward-char n) - (forward-char n))) + (if visual-order-cursor-movement + (dotimes (i (if (numberp n) (abs n) 1)) + (move-point-visually (if (and (numberp n) (< n 0)) 1 -1))) + (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). @@ -898,6 +912,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key goto-map "\M-n" 'next-error) (define-key goto-map "p" 'previous-error) (define-key goto-map "\M-p" 'previous-error) +(define-key goto-map "\t" 'move-to-column) (defvar search-map (make-sparse-keymap) "Keymap for search related commands.") @@ -907,6 +922,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key search-map "hr" 'highlight-regexp) (define-key search-map "hp" 'highlight-phrase) (define-key search-map "hl" 'highlight-lines-matching-regexp) +(define-key search-map "h." 'highlight-symbol-at-point) (define-key search-map "hu" 'unhighlight-regexp) (define-key search-map "hf" 'hi-lock-find-patterns) (define-key search-map "hw" 'hi-lock-write-interactive-patterns) @@ -1204,7 +1220,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key map "n" 'number-to-register) (define-key map "+" 'increment-register) (define-key map "w" 'window-configuration-to-register) - (define-key map "f" 'frame-configuration-to-register) + (define-key map "f" 'frameset-to-register) map) "Keymap for subcommands of C-x r.") (define-key ctl-x-map "r" ctl-x-r-map)