]> code.delx.au - gnu-emacs/blobdiff - lisp/bindings.el
* bitmaps/README:
[gnu-emacs] / lisp / bindings.el
index bee285a30b22c94776576bd17faf3ad9fad3a403..559c3a357515a63c34053624b10703138e440068 100644 (file)
@@ -8,10 +8,10 @@
 
 ;; 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,9 +19,7 @@
 ;; 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 <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -138,8 +136,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))))))
@@ -260,15 +257,16 @@ Normally nil in most modes, since there is no process to display.")
 (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)))))))
+                                          (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.")
 
 (make-variable-buffer-local 'mode-line-remote)
@@ -282,11 +280,16 @@ buffer size, the line number and the column number.")
 (defvar mode-line-modes nil
   "Mode-line control for displaying major and minor modes.")
 
+(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 "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.")
 
@@ -294,11 +297,26 @@ Keymap to display on major mode.")
   (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 "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 "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?
@@ -308,6 +326,7 @@ Keymap to display on minor modes.")
        "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")
        (dashes (propertize "--" 'help-echo help-echo))
        (standard-mode-line-format
        (list
@@ -329,7 +348,8 @@ mouse-3: Remove current window from display")
         (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 "Major mode\n\
 mouse-1: Display major mode menu\n\
@@ -349,30 +369,47 @@ mouse-3: Toggle minor modes"
                     '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)
+        (propertize "--" 'help-echo help-echo)))
 
        (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"
+               'local-map mode-line-column-line-number-mode-map
+               'mouse-face 'mode-line-highlight
                ;; XXX needs better description
-               'help-echo (format "Size indication mode\n%s" help-echo))))
+               '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
-                  (format "Line number and Column number\n%s" help-echo)))
+                  '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"
-                 'help-echo
-                 (format "Line number\n%s" help-echo)))))
+                 '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
-                 (format "Column number\n%s" help-echo)))))))))
+                 '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
@@ -460,19 +497,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))
@@ -526,10 +550,6 @@ Menu of mode operations in the mode line.")
              :help "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 on minor modes area of the mode line."
   (interactive "@e")
@@ -545,12 +565,11 @@ Actually, STRING need not be a string; any possible mode-line element
 is okay.  See `mode-line-format'.")
 ;; 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
@@ -564,10 +583,6 @@ 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")))
@@ -583,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
@@ -616,7 +632,7 @@ is okay.  See `mode-line-format'.")
        "^No later matching history item$"
        "^No earlier matching history item$"
        "^End of history; no default available$"
-       "^End of history; no next item$"
+       "^End of defaults; 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$"
@@ -680,10 +696,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)
@@ -724,10 +743,10 @@ language you are using."
 (define-key esc-map "!" 'shell-command)
 (define-key esc-map "|" 'shell-command-on-region)
 
-(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)
@@ -742,7 +761,7 @@ language you are using."
   ;; 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 minibuffer-local-map [C-tab] 'file-cache-minibuffer-complete))
+  (define-key map [C-tab] 'file-cache-minibuffer-complete))
 
 (define-key global-map "\C-u" 'universal-argument)
 (let ((i ?0))
@@ -784,16 +803,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)
@@ -1054,25 +1088,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)
@@ -1092,16 +1111,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)