(mode-line-mode-menu): Reverse the order
[bpt/emacs.git] / lisp / bindings.el
index 66a8c51..d156360 100644 (file)
@@ -1,6 +1,7 @@
 ;;; bindings.el --- define standard key bindings and some variables.
 
-;; Copyright (C) 1985,86,87,92,93,94,95,96 Free Software Foundation, Inc.
+;; Copyright (C) 1985,86,87,92,93,94,95,96,99,2000
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -33,8 +34,7 @@
 ;;; 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.  Otherwise, the string will not go
-;;; anywhere!
+;;; 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.
 
 ;;; Code:
 
-(defconst mode-line-mule-info
-  (purecopy '(enable-multibyte-characters
-             ((current-input-method ("[" current-input-method-title "]"))
-              "%z:")))
-  "Mode-line control for displaying information of multilingual environment.")
+(defun make-mode-line-mouse2-map (f) "\
+Return a keymap with single entry for mouse-2 on mode line.
+This is defined to run function F with no args in the buffer
+corresponding to the mode line clicked."
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mode-line mouse-2] f)
+    map))
+
+
+(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)))
+    (toggle-read-only)
+    (force-mode-line-update)))
+
+
+(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)))
+    (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)))
+    (widen)
+    (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]
+      (lambda (e)
+       (interactive "e")
+       (save-selected-window
+         (select-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)))
+         (describe-current-input-method))))
+    (purecopy map)))
+
+(defvar mode-line-mule-info
+  `(""
+    (current-input-method
+     (:eval
+      ,(purecopy
+       '(propertize current-input-method-title
+                    'help-echo (concat
+                                "Input method: "
+                                current-input-method
+                                ".  mouse-2 disables, mouse-3 describes")
+                    'local-map mode-line-input-method-map))))
+    ,(propertize
+      "%Z"
+      'help-echo 
+      (purecopy (lambda (window object point)
+                 (save-window-excursion
+                   (select-window window)
+                   (if enable-multibyte-characters
+                       (concat (symbol-name buffer-file-coding-system)
+                               " buffer; see M-x describe-coding-system")
+                     (concat "Unibyte "
+                             (symbol-name buffer-file-coding-system)
+                             " buffer")))))))
+  "Mode-line control for displaying information of multilingual environment.
+Normally it displays current input method (if any activated) and
+mnemonics of the following coding systems:
+  coding system for saving or writing the current buffer
+  coding system for keyboard input (if Emacs is running on terminal)
+  coding system for terminal output (if Emacs is running on terminal)"
+;; Currently not:
+;;;  coding system for decoding output of buffer process (if any)
+;;;  coding system for encoding text to send to buffer process (if any)."
+)
 
 (make-variable-buffer-local 'mode-line-mule-info)
 
-(defvar mode-line-buffer-identification (purecopy '("%F: %12b"))
-  "Mode-line control for identifying the buffer being displayed.
-Its default value is (\"%F: %12b\").  Under X, `%F' is replaced with `Emacs'.
+(defvar mode-line-buffer-identification (purecopy '("%12b")) "\
+Mode-line control for identifying the buffer being displayed.
+Its default value is (\"%12b\").
 Major modes that edit things other than ordinary files may change this
 \(e.g. Info, Dired,...)")
 
 (make-variable-buffer-local 'mode-line-buffer-identification)
 
-(defvar mode-line-process nil
-  "Mode-line control for displaying info on process status.
+(defvar mode-line-frame-identification '("-%F  "))
+
+(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.")
 
 (make-variable-buffer-local 'mode-line-process)
 
-(defvar mode-line-modified (purecopy '("--%1*%1+-"))
+(defvar mode-line-modified
+  (list (propertize
+        "%1*"
+        'help-echo (purecopy (lambda (window object point)
+                               (format "%sead-only: mouse-2 toggles"
+                                       (save-selected-window
+                                         (select-window window)
+                                         (if buffer-read-only
+                                             "R"
+                                           "Not r")))))
+        'local-map (purecopy (make-mode-line-mouse2-map
+                              #'mode-line-toggle-read-only)))
+       (propertize
+        "%1+"
+        'help-echo  (purecopy (lambda (window object point)
+                                (format "%sodified: mouse-2 toggles flag"
+                                        (save-selected-window
+                                          (select-window window)
+                                          (if (buffer-modified-p)
+                                            "M"
+                                          "Not m")))))
+        'local-map (purecopy (make-mode-line-mouse2-map
+                              #'mode-line-toggle-modified))))
   "Mode-line control for displaying whether current buffer is modified.")
 
 (make-variable-buffer-local 'mode-line-modified)
 
 (setq-default mode-line-format
-  (list (purecopy "")
-   'mode-line-mule-info
-   'mode-line-modified
-   'mode-line-buffer-identification
-   (purecopy "   ")
-   'global-mode-string
-   (purecopy "   %[(")
-   'mode-name 'mode-line-process 'minor-mode-alist
-   (purecopy "%n")
-   (purecopy ")%]--")
-   (purecopy '(line-number-mode "L%l--"))
-   (purecopy '(column-number-mode "C%c--"))
-   (purecopy '(-3 . "%p"))
-   (purecopy "-%-")))
+  (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 window, mouse-2: delete others, mouse-3: delete ...")
+        (dashes (propertize "--" 'help-echo help-echo)))
+    (list
+     (propertize "-" 'help-echo help-echo)
+     'mode-line-mule-info
+     'mode-line-modified
+     'mode-line-frame-identification
+     'mode-line-buffer-identification
+     (propertize "   " 'help-echo help-echo)
+     'global-mode-string
+     (propertize "   %[(" 'help-echo help-echo)
+     '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist
+     (propertize "%n" 'help-echo "mouse-2: widen"
+                'local-map (make-mode-line-mouse2-map #'mode-line-widen))
+     (propertize ")%]--" 'help-echo help-echo)
+     `(which-func-mode ("" which-func-format ,dashes))
+     `(line-number-mode ("L%l" ,dashes))
+     `(column-number-mode ("C%c" ,dashes))
+     (purecopy '(-3 . "%p"))
+     (propertize "-%-" 'help-echo help-echo))))
 
 (defvar minor-mode-alist nil "\
 Alist saying how to show minor modes in the mode line.
@@ -98,11 +235,150 @@ STRING is included in the mode line iff VARIABLE's value is non-nil.
 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 '((abbrev-mode " Abbrev")
-                        (overwrite-mode overwrite-mode)
-                        (auto-fill-function " Fill")
-                        ;; not really a minor mode...
-                        (defining-kbd-macro " Def")))
+(setq minor-mode-alist
+      (list
+       (list 'abbrev-mode
+            (propertize " Abbrev"
+                        'help-echo (purecopy
+                                    "mouse-2: turn off Abbrev mode")
+                        'local-map (purecopy (make-mode-line-mouse2-map
+                                              #'mode-line-abbrev-mode))))
+       '(overwrite-mode overwrite-mode)
+       (list 'auto-fill-function
+            (propertize " Fill"
+                        'help-echo (purecopy
+                                    "mouse-2: turn off Autofill mode")
+                        'local-map (purecopy (make-mode-line-mouse2-map
+                                              #'mode-line-auto-fill-mode))))
+       ;; not really a minor mode...
+       '(defining-kbd-macro " Def")))
+
+(defvar mode-line-buffer-identification-keymap nil "\
+Keymap for what is displayed by `mode-line-buffer-identification'.")
+
+(defvar mode-line-minor-mode-keymap nil "\
+Keymap for what is displayed by `mode-line-mode-name'.")
+
+(defvar mode-line-mode-menu-keymap nil "\
+Keymap for mode operations menu in the mode line.")
+
+(defun mode-line-unbury-buffer () "\
+Switch to the last buffer in the buffer list that is not hidden."
+  (interactive)
+  (let ((list (reverse (buffer-list))))
+    (while (eq (aref (buffer-name (car list)) 0) ? )
+      (setq list (cdr list)))
+    (switch-to-buffer (car list))))
+
+(defun mode-line-other-buffer () "\
+Switch to the most recently selected buffer other than the current one."
+  (interactive)
+  (switch-to-buffer (other-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)))))
+
+(defun mode-line-mode-name () "\
+Return a string to display in the mode line for the current mode name."
+  (let (length (result mode-name))
+    (let ((local-map (get-text-property 0 'local-map result))
+         (help-echo (get-text-property 0 'help-echo result)))
+      (setq result (copy-sequence result))
+      ;; Add `local-map' property if there isn't already one.
+      (when (and (null local-map)
+                (null (next-single-property-change 0 'local-map result)))
+       (put-text-property 0 (length result)
+                          'local-map mode-line-minor-mode-keymap result))
+      ;; Add `help-echo' property if there isn't already one.
+      (when (and (null help-echo)
+                (null (next-single-property-change 0 'help-echo result)))
+       (put-text-property 0 (length result)
+                          'help-echo "mouse-3: minor mode menu" result)))
+    result))
+
+(defmacro bound-and-true-p (var)
+  "Return the value of symbol VAR if it is bound, else nil."
+  `(and (boundp (quote ,var)) ,var))
+
+(define-key mode-line-mode-menu [overwrite-mode]
+  `(menu-item ,(purecopy "Overwrite") overwrite-mode
+             :button (:toggle . overwrite-mode)))
+(define-key mode-line-mode-menu [outline-minor-mode]
+  `(menu-item ,(purecopy "Outline") outline-minor-mode
+             :button (:toggle . (bound-and-true-p outline-minor-mode))))
+(define-key mode-line-mode-menu [line-number-mode]
+  `(menu-item ,(purecopy "Line number") line-number-mode
+             :button (:toggle . line-number-mode)))
+(define-key mode-line-mode-menu [highlight-changes-mode]
+  `(menu-item ,(purecopy "Highlight changes") highlight-changes-mode
+             :button (:toggle . highlight-changes-mode)))
+(define-key mode-line-mode-menu [hide-ifdef-mode]
+  `(menu-item ,(purecopy "Hide ifdef") hide-ifdef-mode
+             :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
+(define-key mode-line-mode-menu [font-lock-mode]
+  `(menu-item ,(purecopy "Font-lock") font-lock-mode
+             :button (:toggle . font-lock-mode)))
+(define-key mode-line-mode-menu [flyspell-mode]
+  `(menu-item ,(purecopy "Flyspell") flyspell-mode
+             :button (:toggle . (bound-and-true-p flyspell-mode))))
+(define-key mode-line-mode-menu [column-number-mode]
+  `(menu-item ,(purecopy "Column number") column-number-mode
+             :button (:toggle . column-number-mode)))
+(define-key mode-line-mode-menu [auto-fill-mode]
+  `(menu-item ,(purecopy "Auto-fill") auto-fill-mode
+             :button (:toggle . auto-fill-function)))
+(define-key mode-line-mode-menu [auto-revert-mode]
+  `(menu-item ,(purecopy "Auto revert") auto-revert-mode
+             :button (:toggle . auto-revert-mode)))
+(define-key mode-line-mode-menu [abbrev-mode]
+  `(menu-item ,(purecopy "Abbrev") abbrev-mode
+             :button (:toggle . abbrev-mode)))
+
+(defun mode-line-mode-menu (event)
+  (interactive "@e")
+  (x-popup-menu event mode-line-mode-menu))
+
+;; Add menu of buffer operations to the buffer identification part
+;; of the mode line.
+(let ((map (make-sparse-keymap)))
+  (define-key map [mode-line mouse-1] 'mode-line-other-buffer)
+  (define-key map [header-line mouse-1] 'mode-line-other-buffer)
+  (define-key map [mode-line M-mouse-2] 'mode-line-unbury-buffer)
+  (define-key map [header-line M-mouse-2] 'mode-line-unbury-buffer)
+  (define-key map [mode-line mouse-2] 'bury-buffer)
+  (define-key map [header-line mouse-2] 'bury-buffer)
+  (define-key map [mode-line down-mouse-3] 'mouse-buffer-menu)
+  (define-key map [header-line down-mouse-3] 'mouse-buffer-menu)
+  (setq mode-line-buffer-identification-keymap map))
+
+(defun propertized-buffer-identification (fmt)
+  "Return a list suitable for `mode-line-buffer-identification'.
+FMT is a format specifier such as \"%12b\".  This function adds
+text properties for face, help-echo, and local-map to it."
+  (list (propertize fmt
+                   'face '(:weight bold)
+                   'help-echo (purecopy "mouse-1: other \
+buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu")
+                   'local-map mode-line-buffer-identification-keymap)))
+  
+(setq-default mode-line-buffer-identification
+             (propertized-buffer-identification "%12b"))
+
+;; Menu of minor modes.
+(let ((map (make-sparse-keymap)))
+  (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)
+  (setq mode-line-minor-mode-keymap map))
 
 ;; These variables are used by autoloadable packages.
 ;; They are defined here so that they do not get overridden
@@ -121,20 +397,33 @@ is okay.  See `mode-line-format'.")
                ".brn" ".rnt" ".mem" ".lni" ".lis"
                ".olb" ".tlb" ".mlb" ".hlb"))
             (t
-             '(".o" "~" ".bin" ".lbin" ".fasl"
+             '(".o" "~" ".bin" ".lbin" ".fasl" ".ufsl"
                ".a" ".ln" ".blg" ".bbl")))
        '(".elc" ".lof"
         ".glo" ".idx" ".lot"
         ;; TeX-related
-        ".dvi" ".fmt"
+        ".dvi" ".fmt" ".tfm" ".pdf"
+        ;; Java compiled
+        ".class"
+        ;; Clisp
+        ".fas" ".lib"
+        ;; CMUCL
+        ".x86f" ".sparcf"
+        ;; Libtool
+        ".lo" ".la"
+        ;; Java
+        ".class"
         ;; Texinfo-related
         ".toc" ".log" ".aux"
         ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
         ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs")))
 
+;; 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
        end-of-buffer end-of-file buffer-read-only
+       file-supersession
        "^Previous command was not a yank$"
        "^Minibuffer window is not active$"
        "^End of history; no next item$"
@@ -145,87 +434,97 @@ is okay.  See `mode-line-format'.")
        "^No further undo information$"
        "^Save not confirmed$"
        "^Recover-file cancelled\\.$"
+       "^Cannot switch buffers in a dedicated window$"
+       
+       ;; ediff
+       "^Errors in diff output. Diff output is in "
+       "^Hmm... I don't see an Ediff command around here...$"
+       "^Undocumented command! Type `G' in Ediff Control Panel to drop a note to the Ediff maintainer$"
+       ": This command runs in Ediff Control Buffer only!$"
+       ": Invalid op in ediff-check-version$"
+       "^ediff-shrink-window-C can be used only for merging jobs$"
+       "^Lost difference info on these directories$"
+       "^This command is inapplicable in the present context$"
+       "^This session group has no parent$"
+       "^Can't hide active session, $"
+       "^Ediff: something wrong--no multiple diffs buffer$"
+       "^Can't make context diff for Session $"
+       "^The patch buffer wasn't found$"
+       "^Aborted$"
+       "^This Ediff session is not part of a session group$"
+       "^No active Ediff sessions or corrupted session registry$"
+       "^No session info in this line$"
+       "^`.*' is not an ordinary file$"
+       "^Patch appears to have failed$"
+       "^Recomputation of differences cancelled$"
+       "^No fine differences in this mode$"
+       "^Lost connection to ancestor buffer...sorry$"
+       "^Not merging with ancestor$"
+       "^Don't know how to toggle read-only in buffer "
+       "Emacs is not running as a window application$"
+       "^This command makes sense only when merging with an ancestor$"
+       "^At end of the difference list$"
+       "^At beginning of the difference list$"
+       "^Nothing saved for diff .* in buffer "
+       "^Buffer is out of sync for file "
+       "^Buffer out of sync for file "
+       "^Output from `diff' not found$"
+       "^You forgot to specify a region in buffer "
+       "^All right. Make up your mind and come back...$"
+       "^Current buffer is not visiting any file$"
+       "^Failed to retrieve revision: $"
+       "^Can't determine display width.$"
+       "^File `.*' does not exist or is not readable$"
+       "^File `.*' is a directory$"
+       "^Buffer .* doesn't exist$"
+       "^Directories . and . are the same: "
+       "^Directory merge aborted$"
+       "^Merge of directory revisions aborted$"
+       "^Buffer .* doesn't exist$"
+       "^There is no file to merge$"
+       "^Version control package .*.el not found. Use vc.el instead$"))
 
-       ;; comint
-       "^Not at command line$"
-       "^Empty input ring$"
-       "^No history$"
-       "^Not found$";; To common?
-       "^Current buffer has no process$"
-
-       ;; dabbrev
-       "^No dynamic expansion for \".*\" found\\.$"
-       "^No further dynamic expansions for \".*\" found\\.$"
-       "^No further dynamic expansions for `.*' found$"
-
-       ;; Completion
-       "^To complete, the point must be after a symbol at least [0-9]* character long\\.$"
-       "^The string \".*\" is too short to be saved as a completion\\.$"
-
-       ;; Compile
-       "^No more errors\\( yet\\|\\)$"
-
-       ;; Gnus
-       "^NNTP: Connection closed\\.$"
-
-       ;; info
-       "^Node has no Previous$"
-       "^No \".*\" in index$"
-
-       ;; imenu
-       "^No items suitable for an index found in this buffer\\.$"
-       "^The mode \".*\" does not take full advantage of imenu\\.el yet\\.$"
-
-       ;; ispell
-       "^No word found to check!$"
 
-       ;; mh-e
-       "^Cursor not pointing to message$"
-       "^There is no other window$"
-
-       ;; man
-       "^No manpage [0-9]* found$"
-
-       ;; etags
-       "^No tags table in use!  Use .* to select one\\.$"
-       "^There is no default tag$"
-       "^No previous tag locations$"
-       "^File .* is not a valid tags table$"
-       "^No \\(more \\|\\)tags \\(matching\\|containing\\) "
-       "^Rerun etags: `.*' not found in "
-       "^All files processed\\.$"
-       "^No .* or .* in progress.$"
-       "^File .* not in current tags tables$"
-       "No tags table loaded."
-       "^Nothing to complete$"
-
-       ;; BBDB
-       "^no previous record$"
-       "^no next record$"))
+(make-variable-buffer-local 'indent-tabs-mode)
 
+;; We have base64 functions built in now.
+(add-to-list 'features 'base64)
 
-(make-variable-buffer-local 'indent-tabs-mode)
+(define-key esc-map "\t" 'complete-symbol)
 
-;; This is here to avoid autoloading etags on M-TAB.
-;; M-x visit-tags-table will autoload etags, which will redefine complete-tag.
-(defun complete-tag ()
-  "Perform tags completion on the text around point.
+(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)."
-  (interactive)
-  (error (substitute-command-keys
-         "No tags table loaded.  Try \\[visit-tags-table].")))
+for \\[find-tag] (which see).
+
+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")))))
 
 ;; Reduce total amount of space we must allocate during this function
 ;; that we will not need to keep permanently.
 (garbage-collect)
 \f
-(define-key ctl-x-map "n" (make-sparse-keymap))
-(define-key ctl-x-map "r" (make-sparse-keymap))
+;; Make all multibyte characters self-insert.
+(let ((l (generic-character-list))
+      (table (nth 1 global-map)))
+  (while l
+    (set-char-table-default table (car l) 'self-insert-command)
+    (setq l (cdr l))))
 
 (setq help-event-list '(help f1))
 
+(make-variable-buffer-local 'minor-mode-overriding-map-alist)
+
 ;These commands are defined in editfns.c
 ;but they are not assigned to keys there.
 (put 'narrow-to-region 'disabled t)
@@ -301,10 +600,10 @@ for \\[find-tag] (which see)."
 
 (define-key global-map "\C-@" 'set-mark-command)
 ;; Many people are used to typing C-SPC and getting C-@.
-(define-key global-map [?\C-\ ] 'set-mark-command)
+(define-key global-map [?\C- ] 'set-mark-command)
 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
 (define-key ctl-x-map "\C-@" 'pop-global-mark)
-(define-key ctl-x-map [?\C-\ ] 'pop-global-mark)
+(define-key ctl-x-map [?\C- ] 'pop-global-mark)
 
 (define-key global-map "\C-n" 'next-line)
 (define-key global-map "\C-p" 'previous-line)
@@ -317,6 +616,8 @@ for \\[find-tag] (which see)."
 (define-key global-map [menu] 'execute-extended-command)
 (define-key global-map [find] 'search-forward)
 
+(define-key global-map [delete] 'delete-char)
+
 ;; natural bindings for terminal keycaps --- defined in X keysym order
 (define-key global-map [home]          'beginning-of-buffer)
 (define-key global-map [M-home]                'beginning-of-buffer-other-window)
@@ -433,10 +734,10 @@ for \\[find-tag] (which see)."
 (define-key esc-map "\C-t" 'transpose-sexps)
 (define-key ctl-x-map "\C-t" 'transpose-lines)
 
-(define-key esc-map ";" 'indent-for-comment)
-(define-key esc-map "j" 'indent-new-comment-line)
-(define-key esc-map "\C-j" 'indent-new-comment-line)
-(define-key ctl-x-map ";" 'set-comment-column)
+(define-key esc-map ";" 'comment-dwim)
+(define-key esc-map "j" 'comment-indent-new-line)
+(define-key esc-map "\C-j" 'comment-indent-new-line)
+(define-key ctl-x-map ";" 'comment-set-column)
 (define-key ctl-x-map "f" 'set-fill-column)
 (define-key ctl-x-map "$" 'set-selective-display)
 
@@ -475,6 +776,8 @@ for \\[find-tag] (which see)."
 (define-key esc-map "\C-k" 'kill-sexp)
 (define-key global-map [C-M-delete] 'backward-kill-sexp)
 (define-key global-map [C-M-backspace] 'backward-kill-sexp)
+(define-key esc-map [C-delete] 'backward-kill-sexp)
+(define-key esc-map [C-backspace] 'backward-kill-sexp)
 (define-key esc-map "\C-n" 'forward-list)
 (define-key esc-map "\C-p" 'backward-list)
 (define-key esc-map "\C-a" 'beginning-of-defun)
@@ -483,9 +786,12 @@ for \\[find-tag] (which see)."
 (define-key ctl-x-map "nd" 'narrow-to-defun)
 (define-key esc-map "(" 'insert-parentheses)
 (define-key esc-map ")" 'move-past-close-and-reindent)
-(define-key esc-map "\t" 'lisp-complete-symbol)
 
 (define-key ctl-x-map "\C-e" 'eval-last-sexp)
+
+(define-key ctl-x-map "m" 'compose-mail)
+(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)
@@ -496,6 +802,8 @@ for \\[find-tag] (which see)."
 (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)
@@ -553,6 +861,8 @@ for \\[find-tag] (which see)."
 (define-key esc-map "'" 'abbrev-prefix-mark)
 (define-key ctl-x-map "'" 'expand-abbrev)
 
+(define-key ctl-x-map "z" 'repeat)
+
 ;;; Don't compile this file; it contains no large function definitions.
 ;;; Don't look for autoload cookies in this file.
 ;;; Local Variables: