(Vtruncate_partial_width_windows): Improve docstring.
[bpt/emacs.git] / lisp / bindings.el
index 003c952..9ee6c3f 100644 (file)
@@ -1,7 +1,8 @@
 ;;; 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, 2008 Free Software Foundation, Inc.
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -146,7 +147,7 @@ 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.
@@ -155,7 +156,7 @@ corresponding to the mode line clicked."
             mnemonic
             '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,8 +171,10 @@ corresponding to the mode line clicked."
 (defvar mode-line-client
   `(""
     (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
-                help-echo "Emacsclient frame"))
-  "Mode-line control for identifying Emacsclient frames.")
+                help-echo "emacsclient frame"))
+  "Mode-line control for identifying emacsclient frames.")
+;; Autoload all risky properties if this file no longer dumped.
+(put 'mode-line-client 'risky-local-variable t)
 
 (defvar mode-line-mule-info
   `(""
@@ -213,15 +216,29 @@ mnemonics of the following coding systems:
   ;;  coding system for encoding text to send to buffer process (if any)."
 )
 
+(put 'mode-line-mule-info 'risky-local-variable t)
 (make-variable-buffer-local 'mode-line-mule-info)
 
-(defvar mode-line-frame-identification '(window-system "  " "-%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.")
+(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.")
 
+(put 'mode-line-process 'risky-local-variable t)
 (make-variable-buffer-local 'mode-line-process)
 
 (defvar mode-line-modified
@@ -245,13 +262,14 @@ Normally nil in most modes, since there is no process to display.")
                                         (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.")
 
+(put 'mode-line-modified 'risky-local-variable t)
 (make-variable-buffer-local 'mode-line-modified)
 
 (defvar mode-line-remote
@@ -268,6 +286,7 @@ Normally nil in most modes, since there is no process to display.")
                                             "Current directory is local: ")
                                           default-directory)))))))
   "Mode-line flag to show if default-directory for current buffer is remote.")
+(put 'mode-line-remote 'risky-local-variable t)
 
 (make-variable-buffer-local 'mode-line-remote)
 
@@ -276,9 +295,11 @@ 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.")
+(put 'mode-line-position 'risky-local-variable t)
 
 (defvar mode-line-modes nil
   "Mode-line control for displaying major and minor modes.")
+(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.")
@@ -344,7 +365,7 @@ mouse-3: Remove current window from display")
         (propertize "  " 'help-echo help-echo)
         'mode-line-modes
         `(which-func-mode ("" which-func-format ,dashes))
-        `(global-mode-string (,dashes global-mode-string))
+        `(global-mode-string ("" global-mode-string ,dashes))
         (propertize "-%-" 'help-echo help-echo)))
        (standard-mode-line-modes
        (list
@@ -457,6 +478,7 @@ 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,...)")
 
+(put 'mode-line-buffer-identification 'risky-local-variable t)
 (make-variable-buffer-local 'mode-line-buffer-identification)
 
 (defun unbury-buffer () "\
@@ -563,6 +585,7 @@ 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'.")
+(put 'minor-mode-alist 'risky-local-variable t)
 ;; Don't use purecopy here--some people want to change these strings.
 (setq minor-mode-alist
       '((abbrev-mode " Abbrev")
@@ -583,15 +606,13 @@ is okay.  See `mode-line-format'.")
        (cond ((memq system-type '(ms-dos windows-nt))
              '(".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"))
             (t
              '(".o" "~" ".bin" ".lbin" ".so"
                ".a" ".ln" ".blg" ".bbl")))
        '(".elc" ".lof"
         ".glo" ".idx" ".lot"
+        ;; VCS metadata directories
+        ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
         ;; TeX-related
         ".fmt" ".tfm"
         ;; Java compiled
@@ -602,6 +623,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
@@ -699,10 +721,13 @@ 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)
+
+(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)
@@ -742,11 +767,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)
@@ -803,16 +829,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)
@@ -1027,8 +1068,8 @@ language you are using."
 (global-set-key [C-right]  'forward-word)
 (global-set-key [C-left]   'backward-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)
 
@@ -1073,25 +1114,10 @@ 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)
 \f
-(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 ctl-x-map "." 'set-fill-prefix)
@@ -1111,16 +1137,20 @@ language you are using."
 (define-key ctl-x-map "np" 'narrow-to-page)
 ;; (define-key ctl-x-map "p" 'narrow-to-page)
 \f
-(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)