Mercurial > emacs
changeset 24985:e4f2a5d1dc28
(make-mode-line-mouse-sensitive): Add key
definitions for `top-line'.
(mode-line-format): Replace `mode-name' with
`(:eval mode-line-mode-name)'.
(mode-line-mode-name): New.
(make-mode-line-mouse-sensitive): Don't change default value
of `mode-name'.
(make-mode-line-mouse-sensitive): Use down-mouse-3
instead of mouse-3 to pop up menus.
(make-mode-line-mouse-sensitive): Pop mouse buffer menu over
buffer name.
(mode-line-buffer-menu-1): Removed.
(mode-line-buffer-identification-keymap): New.
(mode-line-buffer-menu-keymap): New.
(mode-line-mode-menu-keymap): New.
(mode-line-unbury-buffer): New.
(mode-line-other-buffer): New.
(mode-line-buffer-menu-1): New.
(mode-line-mode-menu-1): New.
(make-mode-line-mouse-sensitive): New.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 21 Jul 1999 21:43:03 +0000 |
parents | 1553432b90d5 |
children | cf6d86af7374 |
files | lisp/bindings.el |
diffstat | 1 files changed, 129 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/bindings.el Wed Jul 21 21:43:03 1999 +0000 +++ b/lisp/bindings.el Wed Jul 21 21:43:03 1999 +0000 @@ -78,7 +78,21 @@ (make-variable-buffer-local 'mode-line-process) -(defvar mode-line-modified (purecopy '("%1*%1+")) +(defconst mode-line-modified + (let ((s "%1*%1+") + (map (make-sparse-keymap))) + (define-key map [mode-line mouse-2] + (lambda (event) + (interactive "e") + (save-selected-window + (select-window (posn-window (event-start event))) + (toggle-read-only)))) + (set-text-properties 0 (length s) + (list 'help-echo + "Read-only status: mouse-2 toggles it" + 'local-map map) + s) + (list s)) "Mode-line control for displaying whether current buffer is modified.") (make-variable-buffer-local 'mode-line-modified) @@ -92,7 +106,7 @@ (purecopy " ") 'global-mode-string (purecopy " %[(") - 'mode-name 'mode-line-process 'minor-mode-alist + '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist (purecopy "%n") (purecopy ")%]--") '(which-func-mode ("" which-func-format "--")) @@ -115,6 +129,119 @@ ;; 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 (sref (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))) + +(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)) + (when mode-line-mouse-sensitive-p + (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)) + +(defvar mode-line-mouse-sensitive-p nil + "Non-nil means mode line has been made mouse-sensitive.") + +(defun make-mode-line-mouse-sensitive () + (when (and window-system + (not mode-line-mouse-sensitive-p)) + (setq mode-line-mouse-sensitive-p t) + (require 'easymenu) + (easy-menu-define mode-line-mode-menu mode-line-mode-menu-keymap + "Menu of mode operations in the mode line." + '("Minor Modes" + ["Abbrev" abbrev-mode :active t :style toggle + :selected abbrev-mode] + ["Auto revert" auto-revert-mode :active t :style toggle + :selected auto-revert-mode] + ["Auto-fill" auto-fill-mode :active t :style toggle + :selected auto-fill-function] + ["Column number" column-number-mode :active t :style toggle + :selected column-number-mode] + ["Flyspell" flyspell-mode :active t :style toggle + :selected flyspell-mode] + ["Font-lock" font-lock-mode :active t :style toggle + :selected font-lock-mode] + ["Hide ifdef" hide-ifdef-mode :active t :style toggle + :selected hide-ifdef-mode] + ["Highlight changes" highlight-changes-mode :active t :style toggle + :selected highlight-changes-mode] + ["Line number" line-number-mode :active t :style toggle + :selected line-number-mode] + ["Outline" outline-minor-mode :active t :style toggle + :selected outline-minor-mode] + ["Overwrite" overwrite-mode :active t :style toggle + :selected overwrite-mode])) + + ;; Add menu of buffer operations to the buffer identification part + ;; of the mode line. + (let ((map (make-sparse-keymap)) + (s (copy-sequence "%12b"))) + (define-key map [mode-line mouse-1] 'mode-line-other-buffer) + (define-key map [top-line mouse-1] 'mode-line-other-buffer) + (define-key map [mode-line M-mouse-2] 'mode-line-unbury-buffer) + (define-key map [top-line M-mouse-2] 'mode-line-unbury-buffer) + (define-key map [mode-line mouse-2] 'bury-buffer) + (define-key map [top-line mouse-2] 'bury-buffer) + (define-key map [mode-line down-mouse-3] 'mouse-buffer-menu) + (define-key map [top-line down-mouse-3] 'mouse-buffer-menu) + (setq mode-line-buffer-identification-keymap map) + (setq-default mode-line-buffer-identification (list s)) + (put-text-property 0 (length s) 'face '(:weight bold) s) + (put-text-property 0 (length s) 'help-echo + "mouse-1: other buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu" s) + (put-text-property 0 (length s) 'local-map map s)) + + ;; 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 [top-line down-mouse-3] 'mode-line-mode-menu-1) + (setq mode-line-minor-mode-keymap map)) + + (force-mode-line-update))) + + ;; These variables are used by autoloadable packages. ;; They are defined here so that they do not get overridden ;; by the loading of those packages.