]> code.delx.au - gnu-emacs/blobdiff - lisp/bindings.el
Fix typo.
[gnu-emacs] / lisp / bindings.el
index 139232ea0ec5389b04afe38e9d3bd31baeeb8abb..1f86f3b6fcb67e4bff99d63ae4b6d2b859152dae 100644 (file)
@@ -28,7 +28,7 @@
 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ;;; Special formatting conventions are used in this file!
 ;;;
-;;; a backslash-newline is used at the beginning of a documentation string
+;;; 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).
@@ -135,6 +135,40 @@ corresponding to the mode line clicked."
   "Local keymap for the coding-system part of the mode line.")
 
 
+(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)))
+    (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))))))
+
+(defvar mode-line-eol-desc-cache nil)
+
+(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)))
+    (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-3 to cycle"
+                               (if (eq eol 0) "Unix-style LF"
+                                 (if (eq eol 1) "Dos-style CRLF"
+                                   (if (eq eol 2) "Mac-style CR"
+                                     "Undecided"))))
+            'keymap
+            (eval-when-compile
+              (let ((map (make-sparse-keymap)))
+                (define-key map [mode-line mouse-3] 'mode-line-change-eol)
+                map))))
+      (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
+      desc)))
+
 (defvar mode-line-mule-info
   `(""
     (current-input-method
@@ -145,7 +179,7 @@ corresponding to the mode line clicked."
                             ".  mouse-2: disable, mouse-3: describe")
                  local-map ,mode-line-input-method-map))
     ,(propertize
-      "%Z"
+      "%z"
       'help-echo
       #'(lambda (window object point)
          (with-current-buffer (window-buffer window)
@@ -157,16 +191,17 @@ corresponding to the mode line clicked."
                          " buffer; mouse-3: describe coding system")
                (concat "Unibyte " (symbol-name buffer-file-coding-system)
                        " buffer")))))
-      'local-map mode-line-coding-system-map))
+      'local-map mode-line-coding-system-map)
+    (:eval (mode-line-eol-desc)))
   "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)."
+  ;; 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)
@@ -218,19 +253,27 @@ Normally nil in most modes, since there is no process to display.")
 
 ;; Actual initialization is below.
 (defvar mode-line-position nil
-  "Mode-line control for displaying line number, column number and fraction.")
+  "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.")
 
 (defvar mode-line-modes nil
   "Mode-line control for displaying major and minor modes.")
 
-(defvar mode-line-minor-mode-keymap nil "\
-Keymap to display on major and minor modes.")
+(defvar mode-line-major-mode-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mode-line mouse-2] 'describe-mode)
+    (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
+    map) "\
+Keymap to display on major mode.")
 
-;; 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))
+(defvar mode-line-minor-mode-keymap
+  (let ((map (make-sparse-keymap)))
+    (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)
+    map) "\
+Keymap to display on minor modes.")
 
 (let* ((help-echo
        ;; The multi-line message doesn't work terribly well on the
@@ -238,7 +281,7 @@ Keymap to display on major and minor modes.")
        ;;        "\
        ;; 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: delete others, mouse-3: delete")
+       "mouse-1: select (drag to resize), mouse-2: delete others, mouse-3: delete this")
        (dashes (propertize "--" 'help-echo help-echo)))
   (setq-default mode-line-format
     (list
@@ -248,17 +291,23 @@ Keymap to display on major and minor modes.")
      'mode-line-frame-identification
      'mode-line-buffer-identification
      (propertize "   " 'help-echo help-echo)
-     'global-mode-string
+     'mode-line-position
+     '(vc-mode vc-mode)
+     (propertize "   " 'help-echo help-echo)
      'mode-line-modes
      `(which-func-mode ("" which-func-format ,dashes))
-     'mode-line-position
+     `(global-mode-string (,dashes global-mode-string))
      (propertize "-%-" 'help-echo help-echo)))
 
   (setq-default mode-line-modes
     (list
-     (propertize "   %[(" 'help-echo help-echo)
-     `(:propertize ("" mode-name mode-line-process minor-mode-alist)
-                  help-echo "mouse-3: minor mode menu"
+     (propertize "%[(" 'help-echo help-echo)
+     `(:propertize ("" mode-name)
+                  help-echo "mouse-2: help for current major mode"
+                  local-map ,mode-line-major-mode-keymap)
+     '("" mode-line-process)
+     `(:propertize ("" minor-mode-alist)
+                  help-echo "mouse-2: help for minor modes, mouse-3: minor mode menu"
                   local-map ,mode-line-minor-mode-keymap)
      (propertize "%n" 'help-echo "mouse-2: widen"
                 'local-map (make-mode-line-mouse-map
@@ -266,9 +315,15 @@ Keymap to display on major and minor modes.")
      (propertize ")%]--" 'help-echo help-echo)))
 
   (setq-default mode-line-position
-    `((line-number-mode (,(propertize "L%l" 'help-echo help-echo) ,dashes))
-      (column-number-mode (,(propertize "C%c" 'help-echo help-echo) ,dashes))
-      (-3 . ,(propertize "%p" 'help-echo help-echo)))))
+    `((-3 ,(propertize "%p" 'help-echo help-echo))
+      (size-indication-mode
+       (8 ,(propertize " of %I" 'help-echo help-echo)))
+      (line-number-mode
+       ((column-number-mode
+        (10 ,(propertize " (%l,%c)" 'help-echo help-echo))
+        (6 ,(propertize " L%l" 'help-echo help-echo))))
+       ((column-number-mode
+        (5 ,(propertize " C%c" 'help-echo help-echo))))))))
 
 (defvar mode-line-buffer-identification-keymap nil "\
 Keymap for what is displayed by `mode-line-buffer-identification'.")
@@ -378,6 +433,12 @@ Menu of mode operations in the mode line.")
   (interactive "@e")
   (x-popup-menu event mode-line-mode-menu))
 
+(defun mode-line-minor-mode-help (event)
+  "Describe minor mode for EVENT occured on minor modes area of the mode line."
+  (interactive "@e")
+  (let ((indicator (car (nth 4 (car (cdr event))))))
+    (describe-minor-mode-from-indicator indicator)))
+
 ;; Add menu of buffer operations to the buffer identification part
 ;; of the mode line.or header line.
 ;
@@ -452,14 +513,16 @@ is okay.  See `mode-line-format'.")
         ".fas" ".lib" ".mem"
         ;; CMUCL
         ".x86f" ".sparcf"
-         ;; Other CL implementations (Allegro, LispWorks)
-         ".fasl" ".ufsl" ".fsl" ".dxl"
+         ;; Other CL implementations (Allegro, LispWorks, OpenMCL)
+         ".fasl" ".ufsl" ".fsl" ".dxl" ".pfsl"
         ;; Libtool
         ".lo" ".la"
         ;; Gettext
         ".gmo" ".mo"
         ;; Texinfo-related
-        ".toc" ".log" ".aux"
+        ;; This used to contain .log, but that's commonly used for log
+        ;; files you do want to see, not just TeX stuff.  -- fx
+        ".toc" ".aux"
         ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
         ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs")))
 
@@ -581,12 +644,13 @@ language you are using."
 
 (make-variable-buffer-local 'minor-mode-overriding-map-alist)
 
-;; From macros.c
-(define-key ctl-x-map "(" 'start-kbd-macro)
-(define-key ctl-x-map ")" 'end-kbd-macro)
-(define-key ctl-x-map "e" 'call-last-kbd-macro)
 ;; From frame.c
 (global-set-key [switch-frame] 'handle-switch-frame)
+(global-set-key [select-window] 'handle-select-window)
+
+;; FIXME: Do those 3 events really ever reach the global-map ?
+;;        It seems that they can't because they're handled via
+;;        special-event-map which is used at very low-level.  -stef
 (global-set-key [delete-frame] 'handle-delete-frame)
 (global-set-key [iconify-frame] 'ignore-event)
 (global-set-key [make-frame-visible] 'ignore-event)
@@ -687,6 +751,7 @@ language you are using."
 ;(define-key global-map [delete] 'backward-delete-char)
 
 ;; natural bindings for terminal keycaps --- defined in X keysym order
+(define-key global-map [C-S-backspace]  'kill-whole-line)
 (define-key global-map [home]          'beginning-of-line)
 (define-key global-map [C-home]                'beginning-of-buffer)
 (define-key global-map [M-home]                'beginning-of-buffer-other-window)
@@ -715,6 +780,11 @@ language you are using."
 (define-key global-map [S-insert]      'yank)
 (define-key global-map [undo]          'undo)
 (define-key global-map [redo]          'repeat-complex-command)
+(define-key global-map [again]         'repeat-complex-command) ; Sun keyboard
+(define-key global-map [open]          'find-file) ; Sun
+;; The following wouldn't work to interrupt running code since C-g is
+;; treated specially in the event loop.
+;; (define-key global-map [stop]               'keyboard-quit) ; Sun
 ;; (define-key global-map [clearline]  'function-key-error)
 (define-key global-map [insertline]    'open-line)
 (define-key global-map [deleteline]    'kill-line)
@@ -882,8 +952,10 @@ language you are using."
 (define-key esc-map [?\C-\ ] 'mark-sexp)
 (define-key esc-map "\C-d" 'down-list)
 (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)
+;;; These are dangerous in various situations,
+;;; so let's not encourage anyone to use them.
+;;;(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)
@@ -976,4 +1048,5 @@ language you are using."
 ;; no-update-autoloads: t
 ;; End:
 
+;;; arch-tag: 23b5c7e6-e47b-49ed-8c6c-ed213c5fffe0
 ;;; bindings.el ends here