X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/1bb9a689acfe821e0aa777ddf4e074556c7817a1..73b0cd50031a714347109169ceb8bacae338612a:/lisp/bindings.el diff --git a/lisp/bindings.el b/lisp/bindings.el index 9fd4b3b956..4d9f4f09e5 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1,17 +1,18 @@ ;;; bindings.el --- define standard key bindings and some variables -;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994, 1995, 1996, 1999, -;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1992-1996, 1999-2011 +;; Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: internal +;; Package: emacs ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,32 +20,10 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: -;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -;;; Special formatting conventions are used in this file! -;;; -;;; A backslash-newline is used at the beginning of a documentation string -;;; when that string should be stored in the file etc/DOCnnn, not in core. -;;; -;;; Such strings read into Lisp as numbers (during the pure-loading phase). -;;; -;;; But you must obey certain rules to make sure the string is understood -;;; and goes into etc/DOCnnn properly. -;;; -;;; The doc string must appear in the standard place in a call to -;;; defun, autoload, defvar or defconst. No Lisp macros are recognized. -;;; The open-paren starting the definition must appear in column 0. -;;; -;;; In defvar and defconst, there is an additional rule: -;;; The double-quote that starts the string must be on the same -;;; line as the defvar or defconst. -;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ;;; Code: (defun make-mode-line-mouse-map (mouse function) "\ @@ -83,24 +62,6 @@ corresponding to the mode line clicked." (force-mode-line-update))) -(defun mode-line-abbrev-mode (event) - "Turn off `abbrev-mode' from the mode-line." - (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) - (abbrev-mode) - (force-mode-line-update))) - - -(defun mode-line-auto-fill-mode (event) - "Turn off `auto-fill-mode' from the mode-line." - (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) - (auto-fill-mode) - (force-mode-line-update))) - - (defvar mode-line-input-method-map (let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-2] @@ -138,8 +99,7 @@ corresponding to the mode line clicked." (defun mode-line-change-eol (event) "Cycle through the various possible kinds of end-of-line styles." (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) + (with-selected-window (posn-window (event-start event)) (let ((eol (coding-system-eol-type buffer-file-coding-system))) (set-buffer-file-coding-system (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix)))))) @@ -149,16 +109,16 @@ corresponding to the mode line clicked." (defun mode-line-eol-desc () (let* ((eol (coding-system-eol-type buffer-file-coding-system)) (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system)) - (desc (assq eol mode-line-eol-desc-cache))) + (desc (assoc eol mode-line-eol-desc-cache))) (if (and desc (eq (cadr desc) mnemonic)) (cddr desc) (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale. (setq desc (propertize mnemonic - 'help-echo (format "%s end-of-line; mouse-1 to cycle" + 'help-echo (format "End-of-line style: %s\nmouse-1 to cycle" (if (eq eol 0) "Unix-style LF" - (if (eq eol 1) "Dos-style CRLF" + (if (eq eol 1) "DOS-style CRLF" (if (eq eol 2) "Mac-style CR" "Undecided")))) 'keymap @@ -170,14 +130,24 @@ corresponding to the mode line clicked." (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) desc))) +(defvar mode-line-client + `("" + (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" ""))) + help-echo ,(purecopy "emacsclient frame"))) + "Mode-line control for identifying emacsclient frames.") +;;;###autoload +(put 'mode-line-client 'risky-local-variable t) + (defvar mode-line-mule-info `("" (current-input-method (:propertize ("" current-input-method-title) help-echo (concat - "Input method: " + ,(purecopy "Current input method: ") current-input-method - ". mouse-2: disable, mouse-3: describe") + ,(purecopy "\n\ +mouse-2: Disable input method\n\ +mouse-3: Describe current input method")) local-map ,mode-line-input-method-map mouse-face mode-line-highlight)) ,(propertize @@ -188,11 +158,12 @@ corresponding to the mode line clicked." ;; Don't show this tip if the coding system is nil, ;; it reads like a bug, and is not useful anyway. (when buffer-file-coding-system - (if enable-multibyte-characters - (concat (symbol-name buffer-file-coding-system) - " buffer; mouse-1: describe coding system") - (concat "Unibyte " (symbol-name buffer-file-coding-system) - " buffer"))))) + (format "Buffer coding system %s\nmouse-1: describe coding system" + (if enable-multibyte-characters + (concat "(multi-byte): " + (symbol-name buffer-file-coding-system)) + (concat "(unibyte): " + (symbol-name buffer-file-coding-system))))))) 'mouse-face 'mode-line-highlight 'local-map mode-line-coding-system-map) (:eval (mode-line-eol-desc))) @@ -207,27 +178,44 @@ mnemonics of the following coding systems: ;; coding system for encoding text to send to buffer process (if any)." ) +;;;###autoload +(put 'mode-line-mule-info 'risky-local-variable t) (make-variable-buffer-local 'mode-line-mule-info) -(defvar mode-line-frame-identification '("-%F ") +;; MSDOS frames have window-system, but want the Fn identification. +(defun mode-line-frame-control () + "Compute mode-line control for frame identification. +Value is used for `mode-line-frame-identification', which see." + (if (or (null window-system) + (eq window-system 'pc)) + "-%F " + " ")) + +;; We need to defer the call to mode-line-frame-control to the time +;; the mode line is actually displayed. +(defvar mode-line-frame-identification '(:eval (mode-line-frame-control)) "Mode-line control to describe the current frame.") +;;;###autoload +(put 'mode-line-frame-identification 'risky-local-variable t) (defvar mode-line-process nil "\ Mode-line control for displaying info on process status. Normally nil in most modes, since there is no process to display.") +;;;###autoload +(put 'mode-line-process 'risky-local-variable t) (make-variable-buffer-local 'mode-line-process) (defvar mode-line-modified (list (propertize "%1*" 'help-echo (purecopy (lambda (window object point) - (format "%sead-only: mouse-1 toggles" + (format "Buffer is %s\nmouse-1 toggles" (save-selected-window (select-window window) (if buffer-read-only - "R" - "Not r"))))) + "read-only" + "writable"))))) 'local-map (purecopy (make-mode-line-mouse-map 'mouse-1 #'mode-line-toggle-read-only)) @@ -235,32 +223,37 @@ Normally nil in most modes, since there is no process to display.") (propertize "%1+" 'help-echo (purecopy (lambda (window object point) - (format "%sodified: mouse-1 toggles" + (format "Buffer is %sodified\nmouse-1 toggles modified state" (save-selected-window (select-window window) (if (buffer-modified-p) - "M" - "Not m"))))) + "m" + "not m"))))) 'local-map (purecopy (make-mode-line-mouse-map 'mouse-1 #'mode-line-toggle-modified)) 'mouse-face 'mode-line-highlight)) "Mode-line control for displaying whether current buffer is modified.") +;;;###autoload +(put 'mode-line-modified 'risky-local-variable t) (make-variable-buffer-local 'mode-line-modified) (defvar mode-line-remote (list (propertize "%1@" + 'mouse-face 'mode-line-highlight 'help-echo (purecopy (lambda (window object point) (format "%s" (save-selected-window (select-window window) - (concat - (if (file-remote-p default-directory) - "Remote: " - "Local: ") - default-directory))))))) + (concat + (if (file-remote-p default-directory) + "Current directory is remote: " + "Current directory is local: ") + default-directory))))))) "Mode-line flag to show if default-directory for current buffer is remote.") +;;;###autoload +(put 'mode-line-remote 'risky-local-variable t) (make-variable-buffer-local 'mode-line-remote) @@ -269,39 +262,68 @@ Normally nil in most modes, since there is no process to display.") "Mode-line control for displaying the position in the buffer. Normally displays the buffer percentage and, optionally, the buffer size, the line number and the column number.") +;;;###autoload +(put 'mode-line-position 'risky-local-variable t) (defvar mode-line-modes nil "Mode-line control for displaying major and minor modes.") +;;;###autoload +(put 'mode-line-modes 'risky-local-variable t) + +(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\ +Menu of mode operations in the mode line.") (defvar mode-line-major-mode-keymap (let ((map (make-sparse-keymap))) - (define-key map [mode-line down-mouse-1] 'mouse-major-mode-menu) + (define-key map [mode-line down-mouse-1] + `(menu-item ,(purecopy "Menu Bar") ignore + :filter (lambda (_) (mouse-menu-major-mode-map)))) (define-key map [mode-line mouse-2] 'describe-mode) - (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1) + (define-key map [mode-line down-mouse-3] mode-line-mode-menu) map) "\ Keymap to display on major mode.") (defvar mode-line-minor-mode-keymap (let ((map (make-sparse-keymap))) + (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu) (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help) - (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1) - (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1) + (define-key map [mode-line down-mouse-3] mode-line-mode-menu) + (define-key map [header-line down-mouse-3] mode-line-mode-menu) map) "\ Keymap to display on minor modes.") +(defvar mode-line-column-line-number-mode-map + (let ((map (make-sparse-keymap)) + (menu-map (make-sparse-keymap "Toggle Line and Column Number Display"))) + (define-key menu-map [line-number-mode] + `(menu-item ,(purecopy "Display Line Numbers") line-number-mode + :help ,(purecopy "Toggle displaying line numbers in the mode-line") + :button (:toggle . line-number-mode))) + (define-key menu-map [column-number-mode] + `(menu-item ,(purecopy "Display Column Numbers") column-number-mode + :help ,(purecopy "Toggle displaying column numbers in the mode-line") + :button (:toggle . column-number-mode))) + (define-key map [mode-line down-mouse-1] menu-map) + map) "\ +Keymap to display on column and line numbers.") + (let* ((help-echo ;; The multi-line message doesn't work terribly well on the ;; bottom mode line... Better ideas? ;; "\ ;; mouse-1: select window, mouse-2: delete others, mouse-3: delete, ;; drag-mouse-1: resize, C-mouse-2: split horizontally" - "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0") - (dashes (propertize "--" 'help-echo help-echo)) + "mouse-1: Select (drag to resize)\n\ +mouse-2: Make current window occupy the whole frame\n\ +mouse-3: Remove current window from display") + (recursive-edit-help-echo "Recursive edit, type C-M-c to get out") + (spaces (propertize " " 'help-echo help-echo)) (standard-mode-line-format (list "%e" (propertize "-" 'help-echo help-echo) 'mode-line-mule-info + 'mode-line-client 'mode-line-modified 'mode-line-remote 'mode-line-frame-identification @@ -311,36 +333,74 @@ Keymap to display on minor modes.") '(vc-mode vc-mode) (propertize " " 'help-echo help-echo) 'mode-line-modes - `(which-func-mode ("" which-func-format ,dashes)) - `(global-mode-string (,dashes global-mode-string)) - (propertize "-%-" 'help-echo help-echo))) + `(which-func-mode ("" which-func-format ,spaces)) + `(global-mode-string ("" global-mode-string ,spaces)) + `(:eval (unless (display-graphic-p) + ,(propertize "-%-" 'help-echo help-echo))))) (standard-mode-line-modes (list - (propertize "%[(" 'help-echo help-echo) + (propertize "%[" 'help-echo recursive-edit-help-echo) + (propertize "(" 'help-echo help-echo) `(:propertize ("" mode-name) - help-echo "mouse-1: major mode, mouse-2: major mode help, mouse-3: toggle minor modes" + help-echo "Major mode\n\ +mouse-1: Display major mode menu\n\ +mouse-2: Show help for major mode\n\ +mouse-3: Toggle minor modes" mouse-face mode-line-highlight local-map ,mode-line-major-mode-keymap) '("" mode-line-process) `(:propertize ("" minor-mode-alist) mouse-face mode-line-highlight - help-echo "mouse-2: minor mode help, mouse-3: toggle minor modes" + help-echo "Minor mode\n\ +mouse-1: Display minor mode menu\n\ +mouse-2: Show help for minor mode\n\ +mouse-3: Toggle minor modes" local-map ,mode-line-minor-mode-keymap) - (propertize "%n" 'help-echo "mouse-2: widen" + (propertize "%n" 'help-echo "mouse-2: Remove narrowing from the current buffer" 'mouse-face 'mode-line-highlight 'local-map (make-mode-line-mouse-map 'mouse-2 #'mode-line-widen)) - (propertize ")%]--" 'help-echo help-echo))) + (propertize ")" 'help-echo help-echo) + (propertize "%]" 'help-echo recursive-edit-help-echo) + spaces)) + (standard-mode-line-position - `((-3 ,(propertize "%p" 'help-echo help-echo)) + `((-3 ,(propertize + "%p" + 'local-map mode-line-column-line-number-mode-map + 'mouse-face 'mode-line-highlight + ;; XXX needs better description + 'help-echo "Size indication mode\n\ +mouse-1: Display Line and Column Mode Menu")) (size-indication-mode - (8 ,(propertize " of %I" 'help-echo help-echo))) + (8 ,(propertize + " of %I" + 'local-map mode-line-column-line-number-mode-map + 'mouse-face 'mode-line-highlight + ;; XXX needs better description + 'help-echo "Size indication mode\n\ +mouse-1: Display Line and Column Mode Menu"))) (line-number-mode ((column-number-mode - (10 ,(propertize " (%l,%c)" 'help-echo help-echo)) - (6 ,(propertize " L%l" 'help-echo help-echo)))) + (10 ,(propertize + " (%l,%c)" + 'local-map mode-line-column-line-number-mode-map + 'mouse-face 'mode-line-highlight + 'help-echo "Line number and Column number\n\ +mouse-1: Display Line and Column Mode Menu")) + (6 ,(propertize + " L%l" + 'local-map mode-line-column-line-number-mode-map + 'mouse-face 'mode-line-highlight + 'help-echo "Line Number\n\ +mouse-1: Display Line and Column Mode Menu")))) ((column-number-mode - (5 ,(propertize " C%c" 'help-echo help-echo)))))))) + (5 ,(propertize + " C%c" + 'local-map mode-line-column-line-number-mode-map + 'mouse-face 'mode-line-highlight + 'help-echo "Column number\n\ +mouse-1: Display Line and Column Mode Menu")))))))) (setq-default mode-line-format standard-mode-line-format) (put 'mode-line-format 'standard-value @@ -376,7 +436,9 @@ text properties for face, help-echo, and local-map to it." (list (propertize fmt 'face 'mode-line-buffer-id 'help-echo - (purecopy "mouse-1: previous buffer, mouse-3: next buffer") + (purecopy "Buffer name\n\ +mouse-1: previous buffer\n\ +mouse-3: next buffer") 'mouse-face 'mode-line-highlight 'local-map mode-line-buffer-identification-keymap))) @@ -386,6 +448,8 @@ Its default value is (\"%12b\") with some text properties added. Major modes that edit things other than ordinary files may change this \(e.g. Info, Dired,...)") +;;;###autoload +(put 'mode-line-buffer-identification 'risky-local-variable t) (make-variable-buffer-local 'mode-line-buffer-identification) (defun unbury-buffer () "\ @@ -426,19 +490,6 @@ Switch to the most recently selected buffer other than the current one." (select-window (posn-window (event-start event))) (previous-buffer))) -(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\ -Menu of mode operations in the mode line.") - -(defun mode-line-mode-menu-1 (event) - (interactive "e") - (save-selected-window - (select-window (posn-window (event-start event))) - (let* ((selection (mode-line-mode-menu event)) - (binding (and selection (lookup-key mode-line-mode-menu - (vector (car selection)))))) - (if binding - (call-interactively binding))))) - (defmacro bound-and-true-p (var) "Return the value of symbol VAR if it is bound, else nil." `(and (boundp (quote ,var)) ,var)) @@ -447,45 +498,53 @@ Menu of mode operations in the mode line.") ;; Global ones can go on the menubar (Options --> Show/Hide). (define-key mode-line-mode-menu [overwrite-mode] `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode + :help ,(purecopy "Overwrite mode: typed characters replace existing text") :button (:toggle . overwrite-mode))) (define-key mode-line-mode-menu [outline-minor-mode] `(menu-item ,(purecopy "Outline (Outl)") outline-minor-mode + ;; XXX: This needs a good, brief description. + :help ,(purecopy "") :button (:toggle . (bound-and-true-p outline-minor-mode)))) (define-key mode-line-mode-menu [highlight-changes-mode] `(menu-item ,(purecopy "Highlight changes (Chg)") highlight-changes-mode + :help ,(purecopy "Show changes in the buffer in a distinctive color") :button (:toggle . (bound-and-true-p highlight-changes-mode)))) (define-key mode-line-mode-menu [hide-ifdef-mode] `(menu-item ,(purecopy "Hide ifdef (Ifdef)") hide-ifdef-mode + :help ,(purecopy "Show/Hide code within #ifdef constructs") :button (:toggle . (bound-and-true-p hide-ifdef-mode)))) (define-key mode-line-mode-menu [glasses-mode] `(menu-item ,(purecopy "Glasses (o^o)") glasses-mode + :help ,(purecopy "Insert virtual separators to make long identifiers easy to read") :button (:toggle . (bound-and-true-p glasses-mode)))) (define-key mode-line-mode-menu [font-lock-mode] `(menu-item ,(purecopy "Font Lock") font-lock-mode + :help ,(purecopy "Syntax coloring") :button (:toggle . font-lock-mode))) (define-key mode-line-mode-menu [flyspell-mode] `(menu-item ,(purecopy "Flyspell (Fly)") flyspell-mode + :help ,(purecopy "Spell checking on the fly") :button (:toggle . (bound-and-true-p flyspell-mode)))) (define-key mode-line-mode-menu [auto-revert-tail-mode] `(menu-item ,(purecopy "Auto revert tail (Tail)") auto-revert-tail-mode + :help ,(purecopy "Revert the tail of the buffer when buffer grows") :enable (buffer-file-name) :button (:toggle . (bound-and-true-p auto-revert-tail-mode)))) (define-key mode-line-mode-menu [auto-revert-mode] `(menu-item ,(purecopy "Auto revert (ARev)") auto-revert-mode + :help ,(purecopy "Revert the buffer when the file on disk changes") :button (:toggle . (bound-and-true-p auto-revert-mode)))) (define-key mode-line-mode-menu [auto-fill-mode] `(menu-item ,(purecopy "Auto fill (Fill)") auto-fill-mode + :help ,(purecopy "Automatically insert new lines") :button (:toggle . auto-fill-function))) (define-key mode-line-mode-menu [abbrev-mode] `(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode + :help ,(purecopy "Automatically expand abbreviations") :button (:toggle . abbrev-mode))) -(defun mode-line-mode-menu (event) - (interactive "@e") - (x-popup-menu event mode-line-mode-menu)) - (defun mode-line-minor-mode-help (event) - "Describe minor mode for EVENT occurred on minor modes area of the mode line." + "Describe minor mode for EVENT on minor modes area of the mode line." (interactive "@e") (let ((indicator (car (nth 4 (car (cdr event)))))) (describe-minor-mode-from-indicator indicator))) @@ -497,14 +556,15 @@ STRING is included in the mode line if VARIABLE's value is non-nil. Actually, STRING need not be a string; any possible mode-line element is okay. See `mode-line-format'.") +;;;###autoload +(put 'minor-mode-alist 'risky-local-variable t) ;; Don't use purecopy here--some people want to change these strings. (setq minor-mode-alist - (list - (list 'abbrev-mode " Abbrev") - '(overwrite-mode overwrite-mode) - (list 'auto-fill-function " Fill") - ;; not really a minor mode... - '(defining-kbd-macro " Def"))) + '((abbrev-mode " Abbrev") + (overwrite-mode overwrite-mode) + (auto-fill-function " Fill") + ;; not really a minor mode... + (defining-kbd-macro " Def"))) ;; These variables are used by autoloadable packages. ;; They are defined here so that they do not get overridden @@ -516,19 +576,20 @@ is okay. See `mode-line-format'.") (setq completion-ignored-extensions (append (cond ((memq system-type '(ms-dos windows-nt)) + (mapcar 'purecopy '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk" - ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")) - ((eq system-type 'vax-vms) - '(".obj" ".exe" ".bin" ".lbin" ".sbin" - ".brn" ".rnt" ".lni" - ".olb" ".tlb" ".mlb" ".hlb")) + ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386"))) (t + (mapcar 'purecopy '(".o" "~" ".bin" ".lbin" ".so" - ".a" ".ln" ".blg" ".bbl"))) + ".a" ".ln" ".blg" ".bbl")))) + (mapcar 'purecopy '(".elc" ".lof" ".glo" ".idx" ".lot" + ;; VCS metadata directories + ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/" ;; TeX-related - ".dvi" ".fmt" ".tfm" ".pdf" + ".fmt" ".tfm" ;; Java compiled ".class" ;; CLISP @@ -537,6 +598,7 @@ is okay. See `mode-line-format'.") ".x86f" ".sparcf" ;; Other CL implementations (Allegro, LispWorks, OpenMCL) ".fasl" ".ufsl" ".fsl" ".dxl" ".pfsl" ".dfsl" + ".p64fsl" ".d64fsl" ".dx64fsl" ;; Libtool ".lo" ".la" ;; Gettext @@ -548,7 +610,7 @@ is okay. See `mode-line-format'.") ".cp" ".fn" ".ky" ".pg" ".tp" ".vr" ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs" ;; Python byte-compiled - ".pyc" ".pyo"))) + ".pyc" ".pyo")))) ;; Suffixes used for executables. (setq exec-suffixes @@ -561,24 +623,24 @@ is okay. See `mode-line-format'.") ;; Packages should add to this list appropriately when they are ;; loaded, rather than listing everything here. (setq debug-ignored-errors - '(beginning-of-line beginning-of-buffer end-of-line + `(beginning-of-line beginning-of-buffer end-of-line end-of-buffer end-of-file buffer-read-only file-supersession - "^Previous command was not a yank$" - "^Minibuffer window is not active$" - "^No previous history search regexp$" - "^No later matching history item$" - "^No earlier matching history item$" - "^End of history; no default available$" - "^End of history; no next item$" - "^Beginning of history; no preceding item$" - "^No recursive edit is in progress$" - "^Changes to be undone are outside visible portion of buffer$" - "^No undo information in this buffer$" - "^No further undo information" - "^Save not confirmed$" - "^Recover-file cancelled\\.$" - "^Cannot switch buffers in a dedicated window$" + ,(purecopy "^Previous command was not a yank$") + ,(purecopy "^Minibuffer window is not active$") + ,(purecopy "^No previous history search regexp$") + ,(purecopy "^No later matching history item$") + ,(purecopy "^No earlier matching history item$") + ,(purecopy "^End of history; no default available$") + ,(purecopy "^End of defaults; no next item$") + ,(purecopy "^Beginning of history; no preceding item$") + ,(purecopy "^No recursive edit is in progress$") + ,(purecopy "^Changes to be undone are outside visible portion of buffer$") + ,(purecopy "^No undo information in this buffer$") + ,(purecopy "^No further undo information") + ,(purecopy "^Save not confirmed$") + ,(purecopy "^Recover-file cancelled\\.$") + ,(purecopy "^Cannot switch buffers in a dedicated window$") )) @@ -592,23 +654,15 @@ is okay. See `mode-line-format'.") (define-key esc-map "\t" 'complete-symbol) -(defun complete-symbol (arg) "\ -Perform tags completion on the text around point. -Completes to the set of names listed in the current tags table. -The string to complete is chosen in the same way as the default -for \\[find-tag] (which see). +(defun complete-symbol (arg) + "Perform completion on the text around point. +The completion method is determined by `completion-at-point-functions'. With a prefix argument, this command does completion within the collection of symbols listed in the index of the manual for the language you are using." (interactive "P") - (if arg - (info-complete-symbol) - (if (fboundp 'complete-tag) - (complete-tag) - ;; Don't autoload etags if we have no tags table. - (error (substitute-command-keys - "No tags table loaded; use \\[visit-tags-table] to load one"))))) + (if arg (info-complete-symbol) (completion-at-point))) ;; Reduce total amount of space we must allocate during this function ;; that we will not need to keep permanently. @@ -634,15 +688,79 @@ language you are using." ;These commands are defined in editfns.c ;but they are not assigned to keys there. (put 'narrow-to-region 'disabled t) -(define-key ctl-x-map "nn" 'narrow-to-region) -(define-key ctl-x-map "nw" 'widen) -;; (define-key ctl-x-map "n" 'narrow-to-region) -;; (define-key ctl-x-map "w" 'widen) + +;; 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) + +(define-key narrow-map "n" 'narrow-to-region) +(define-key narrow-map "w" 'widen) ;; Quitting (define-key global-map "\e\e\e" 'keyboard-escape-quit) (define-key global-map "\C-g" 'keyboard-quit) +;; Used to be in termdev.el: when using several terminals, make C-z +;; suspend only the relevant terminal. +(substitute-key-definition 'suspend-emacs 'suspend-frame global-map) + (define-key global-map "\C-j" 'newline-and-indent) (define-key global-map "\C-m" 'newline) (define-key global-map "\C-o" 'open-line) @@ -663,7 +781,8 @@ language you are using." (define-key ctl-x-map "\e\e" 'repeat-complex-command) ;; New binding analogous to M-:. (define-key ctl-x-map "\M-:" 'repeat-complex-command) -(define-key ctl-x-map "u" 'advertised-undo) +(define-key ctl-x-map "u" 'undo) +(put 'undo :advertised-binding [?\C-x ?u]) ;; Many people are used to typing C-/ on X terminals and getting C-_. (define-key global-map [?\C-/] 'undo) (define-key global-map "\C-_" 'undo) @@ -673,11 +792,12 @@ language you are using." (define-key esc-map "!" 'shell-command) (define-key esc-map "|" 'shell-command-on-region) +(define-key esc-map "&" 'async-shell-command) -(define-key global-map [?\C-x right] 'next-buffer) -(define-key global-map [?\C-x C-right] 'next-buffer) -(define-key global-map [?\C-x left] 'previous-buffer) -(define-key global-map [?\C-x C-left] 'previous-buffer) +(define-key ctl-x-map [right] 'next-buffer) +(define-key ctl-x-map [C-right] 'next-buffer) +(define-key ctl-x-map [left] 'previous-buffer) +(define-key ctl-x-map [C-left] 'previous-buffer) (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) @@ -691,7 +811,8 @@ language you are using." ;; Override the global binding (which calls indent-relative via ;; indent-for-tab-command). The alignment that indent-relative tries to ;; do doesn't make much sense here since the prompt messes it up. - (define-key map "\t" 'self-insert-command)) + (define-key map "\t" 'self-insert-command) + (define-key map [C-tab] 'file-cache-minibuffer-complete)) (define-key global-map "\C-u" 'universal-argument) (let ((i ?0)) @@ -712,6 +833,9 @@ language you are using." (setq i (1+ i)))) (define-key global-map [?\C-\M--] 'negative-argument) +(define-key global-map "\177" 'delete-backward-char) +(define-key global-map "\C-d" 'delete-char) + (define-key global-map "\C-k" 'kill-line) (define-key global-map "\C-w" 'kill-region) (define-key esc-map "w" 'kill-ring-save) @@ -733,16 +857,31 @@ language you are using." (define-key ctl-x-map "\C-n" 'set-goal-column) (define-key global-map "\C-a" 'move-beginning-of-line) (define-key global-map "\C-e" 'move-end-of-line) -(define-key esc-map "g" (make-sparse-keymap)) -(define-key esc-map "g\M-g" 'goto-line) -(define-key esc-map "gg" 'goto-line) -(define-key esc-map "gn" 'next-error) -(define-key esc-map "g\M-n" 'next-error) (define-key ctl-x-map "`" 'next-error) -(define-key esc-map "gp" 'previous-error) -(define-key esc-map "g\M-p" 'previous-error) +(defvar goto-map (make-sparse-keymap) + "Keymap for navigation commands.") +(define-key esc-map "g" goto-map) + +(define-key goto-map "g" 'goto-line) +(define-key goto-map "\M-g" 'goto-line) +(define-key goto-map "n" 'next-error) +(define-key goto-map "\M-n" 'next-error) +(define-key goto-map "p" 'previous-error) +(define-key goto-map "\M-p" 'previous-error) + +(defvar search-map (make-sparse-keymap) + "Keymap for search related commands.") +(define-key esc-map "s" search-map) + +(define-key search-map "o" 'occur) +(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 "hu" 'unhighlight-regexp) +(define-key search-map "hf" 'hi-lock-find-patterns) +(define-key search-map "hw" 'hi-lock-write-interactive-patterns) ;;(defun function-key-error () ;; (interactive) @@ -760,12 +899,12 @@ language you are using." (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] 'backward-char) +(define-key global-map [left] 'left-char) (define-key global-map [up] 'previous-line) -(define-key global-map [right] 'forward-char) +(define-key global-map [right] 'right-char) (define-key global-map [down] 'next-line) -(define-key global-map [prior] 'scroll-down) -(define-key global-map [next] 'scroll-up) +(define-key global-map [prior] 'scroll-down-command) +(define-key global-map [next] 'scroll-up-command) (define-key global-map [C-up] 'backward-paragraph) (define-key global-map [C-down] 'forward-paragraph) (define-key global-map [C-prior] 'scroll-right) @@ -804,7 +943,7 @@ language you are using." ;; (define-key global-map [clearline] 'function-key-error) (define-key global-map [insertline] 'open-line) (define-key global-map [deleteline] 'kill-line) -(define-key global-map [deletechar] 'delete-char) +(define-key global-map [deletechar] 'delete-forward-char) ;; (define-key global-map [backtab] 'function-key-error) ;; (define-key global-map [f1] 'function-key-error) ;; (define-key global-map [f2] 'function-key-error) @@ -869,6 +1008,9 @@ language you are using." ;; X11R6 distinguishes these keys from the non-kp keys. ;; Make them behave like the non-kp keys unless otherwise bound. +;; FIXME: rather than list such mappings for every modifier-combination, +;; we should come up with a way to do it generically, something like +;; (define-key function-key-map [*-kp-home] [*-home]) (define-key function-key-map [kp-home] [home]) (define-key function-key-map [kp-left] [left]) (define-key function-key-map [kp-up] [up]) @@ -919,6 +1061,14 @@ language you are using." (define-key function-key-map [C-S-kp-8] [C-S-up]) (define-key function-key-map [C-S-kp-9] [C-S-prior]) +;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@), +;; so we can't distinguish those two keys, but usually we consider C-SPC +;; (rather than C-@) as the "canonical" binding. +(define-key function-key-map [?\C-@] [?\C-\s]) +;; Many keyboards don't have a `backtab' key, so by convention the user +;; can use S-tab instead to access that binding. +(define-key function-key-map [S-tab] [backtab]) + (define-key global-map [mouse-movement] 'ignore) (define-key global-map "\C-t" 'transpose-chars) @@ -954,11 +1104,11 @@ language you are using." (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] 'backward-kill-word) -(global-set-key [C-backspace] 'kill-word) +(global-set-key [C-delete] 'kill-word) +(global-set-key [C-backspace] 'backward-kill-word) ;; This is "move to the clipboard", or as close as we come. (global-set-key [S-delete] 'kill-region) @@ -1003,28 +1153,12 @@ language you are using." (define-key ctl-x-4-map "m" 'compose-mail-other-window) (define-key ctl-x-5-map "m" 'compose-mail-other-frame) -(define-key ctl-x-map "r\C-@" 'point-to-register) -(define-key ctl-x-map [?r ?\C-\ ] 'point-to-register) -(define-key ctl-x-map "r " 'point-to-register) -(define-key ctl-x-map "rj" 'jump-to-register) -(define-key ctl-x-map "rs" 'copy-to-register) -(define-key ctl-x-map "rx" 'copy-to-register) -(define-key ctl-x-map "ri" 'insert-register) -(define-key ctl-x-map "rg" 'insert-register) -(define-key ctl-x-map "rr" 'copy-rectangle-to-register) -(define-key ctl-x-map "rn" 'number-to-register) -(define-key ctl-x-map "r+" 'increment-register) -(define-key ctl-x-map "rc" 'clear-rectangle) -(define-key ctl-x-map "rk" 'kill-rectangle) -(define-key ctl-x-map "rd" 'delete-rectangle) -(define-key ctl-x-map "ry" 'yank-rectangle) -(define-key ctl-x-map "ro" 'open-rectangle) -(define-key ctl-x-map "rt" 'string-rectangle) -(define-key ctl-x-map "rw" 'window-configuration-to-register) -(define-key ctl-x-map "rf" 'frame-configuration-to-register) + +(defvar ctl-x-r-map (make-sparse-keymap) + "Keymap for subcommands of C-x r.") +(define-key ctl-x-map "r" ctl-x-r-map) (define-key esc-map "q" 'fill-paragraph) -;; (define-key esc-map "g" 'fill-region) (define-key ctl-x-map "." 'set-fill-prefix) (define-key esc-map "{" 'backward-paragraph) @@ -1042,16 +1176,20 @@ language you are using." (define-key ctl-x-map "np" 'narrow-to-page) ;; (define-key ctl-x-map "p" 'narrow-to-page) -(define-key ctl-x-map "al" 'add-mode-abbrev) -(define-key ctl-x-map "a\C-a" 'add-mode-abbrev) -(define-key ctl-x-map "ag" 'add-global-abbrev) -(define-key ctl-x-map "a+" 'add-mode-abbrev) -(define-key ctl-x-map "aig" 'inverse-add-global-abbrev) -(define-key ctl-x-map "ail" 'inverse-add-mode-abbrev) -;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev) -(define-key ctl-x-map "a-" 'inverse-add-global-abbrev) -(define-key ctl-x-map "ae" 'expand-abbrev) -(define-key ctl-x-map "a'" 'expand-abbrev) +(defvar abbrev-map (make-sparse-keymap) + "Keymap for abbrev commands.") +(define-key ctl-x-map "a" abbrev-map) + +(define-key abbrev-map "l" 'add-mode-abbrev) +(define-key abbrev-map "\C-a" 'add-mode-abbrev) +(define-key abbrev-map "g" 'add-global-abbrev) +(define-key abbrev-map "+" 'add-mode-abbrev) +(define-key abbrev-map "ig" 'inverse-add-global-abbrev) +(define-key abbrev-map "il" 'inverse-add-mode-abbrev) +;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev) +(define-key abbrev-map "-" 'inverse-add-global-abbrev) +(define-key abbrev-map "e" 'expand-abbrev) +(define-key abbrev-map "'" 'expand-abbrev) ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev) ;; (define-key ctl-x-map "\+" 'add-global-abbrev) ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev) @@ -1061,6 +1199,9 @@ language you are using." (define-key ctl-x-map "z" 'repeat) +(define-key esc-map "\C-l" 'reposition-window) + +(define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window) ;; Signal handlers @@ -1072,5 +1213,4 @@ language you are using." ;; no-update-autoloads: t ;; End: -;; arch-tag: 23b5c7e6-e47b-49ed-8c6c-ed213c5fffe0 ;;; bindings.el ends here