annotate lisp/prim/modeline.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; modeline.el --- modeline hackery.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; General mouse modeline stuff ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar drag-modeline-event-lag 150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 "*The amount of time to wait (in msecs) between drag modeline events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 before updating the display. If this value is too small, dragging will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 be choppy because redisplay cannot keep up. If it is too large, dragging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 will be choppy because of the explicit redisplay delay specified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defvar modeline-click-swaps-buffers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "*If non-nil, clicking on the modeline changes the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Click on the left half of the modeline cycles forward through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 buffer list and clicking on the right half cycles backward.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defun mouse-drag-modeline (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "Resize the window by dragging the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 This should be bound to a mouse button in `modeline-map'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (or (button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (error "%s must be invoked by a mouse-press" this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (or (event-over-modeline-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (error "not over a modeline"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let ((depress-line (event-y event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (mouse-down t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (old-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (def-line-height (face-height 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (prior-drag-modeline-event-time 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (while mouse-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (setq event (next-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (cond ((motion-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (if (window-lowest-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (error "can't drag bottommost modeline"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (cond ((> (- (event-timestamp event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 prior-drag-modeline-event-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 drag-modeline-event-lag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setq prior-drag-modeline-event-time (event-timestamp event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (event-over-modeline-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (setq delta 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (setq delta (- (event-y-pixel event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (nth 3 (window-pixel-edges window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (if (> delta 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq delta (+ delta def-line-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq delta (/ delta def-line-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; cough sputter hack kludge. It shouldn't be possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; to get in here when we are over the minibuffer. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; it is happening and that cause next-vertical-window to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; return nil which does not lead to window-height returning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; anything remotely resembling a sensible value. So catch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; the situation and die a happy death.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; Oh, and the BLAT FOOP error messages suck as well but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; I don't know what should be there. This should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; looked at again when the new redisplay is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (not (next-vertical-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (error "Try again: dragging in minibuffer does nothing"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (cond ((and (> delta 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (<= (- (window-height (next-vertical-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 window-min-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq delta (- (window-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (next-vertical-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 window-min-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (if (< delta 0) (error "BLAT")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ((and (< delta 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (< (+ (window-height window) delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 window-min-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (setq delta (- window-min-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (window-height window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (if (> delta 0) (error "FOOP"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (if (= delta 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (enlarge-window delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; The call to enlarge-window may have caused the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; window to disappear. Don't try and select it in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; that case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (window-live-p old-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (select-window old-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ((button-release-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq mouse-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if modeline-click-swaps-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (mouse-release-modeline event depress-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ((or (button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (key-press-event-p event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (dispatch-event event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; from Bob Weiner (bob_weiner@pts.mot.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defun mouse-release-modeline (event line-num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "Handle modeline click EVENT on LINE-NUM by switching buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 If click on left half of a frame's modeline, bury current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 If click on right half of a frame's modeline, raise bottommost buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Args are: EVENT, the mouse release event, and LINE-NUM, the line number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 within the frame at which the mouse was first depressed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if (= line-num (event-y event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; Button press and release are at same line, treat this as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; a click and switch buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if (< (event-x event) (/ (window-width (event-window event)) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; On left half of modeline, bury current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; displaying second buffer on list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (mouse-bury-buffer event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; On right half of modeline, raise and display bottommost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; buffer in buffer list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (mouse-unbury-buffer event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defconst modeline-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 '("Window Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ["Delete Window Above" delete-window t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ["Delete Other Windows" delete-other-windows t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ["Split Window Above" split-window-vertically t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ["Split Window Horizontally" split-window-horizontally t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ["Balance Windows" balance-windows t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defun modeline-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (popup-menu-and-execute-in-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (cons (format "Window Commands for %S:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (buffer-name (event-buffer event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (cdr modeline-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defvar modeline-map (make-sparse-keymap 'modeline-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "Keymap consulted for mouse-clicks on the modeline of a window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 This variable may be buffer-local; its value will be looked up in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 the buffer of the window whose modeline was clicked upon.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (define-key modeline-map 'button1 'mouse-drag-modeline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; button2 selects the window without setting point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (define-key modeline-map 'button2 (lambda () (interactive "@")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (define-key modeline-map 'button3 'modeline-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (make-face 'modeline-mousable "Face for mousable portions of the modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defmacro make-modeline-command-wrapper (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 `#'(lambda (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (save-selected-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (select-window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (call-interactively ',(eval command)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;; Minor modes ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defvar minor-mode-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Alist saying how to show minor modes in the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 Each element looks like (VARIABLE STRING);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 STRING is included in the modeline iff VARIABLE's value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 Actually, STRING need not be a string; any possible modeline element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 is okay. See `modeline-format'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; Used by C code (lookup-key and friends) but defined here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defvar minor-mode-map-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "Alist of keymaps to use for minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 key sequences and look up bindings iff VARIABLE's value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 If two active keymaps bind the same key, the keymap appearing earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 in the list takes precedence.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (make-face 'modeline-mousable-minor-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Face for mousable minor-mode strings in the modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defvar modeline-mousable-minor-mode-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; alliteration at its finest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 "Extent managing the mousable minor mode modeline strings.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (set-extent-face modeline-mousable-minor-mode-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 'modeline-mousable-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; This replaces the idiom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; (or (assq 'isearch-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; (append minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; '((isearch-mode isearch-mode))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun add-minor-mode (toggle name &optional keymap after toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 TOGGLE is a symbol whose value as a variable specifies whether the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 minor mode is active. NAME is the name that should appear in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 modeline (it should be a string beginning with a space). KEYMAP is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 keymap to make active when the minor mode is active. AFTER is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 toggling symbol used for another minor mode. If AFTER is non-nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 then it is used to position the new mode in the minor-mode alists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 TOGGLE-FUN specifies an interactive function that is called to toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 the mode on and off; this affects what happens when button2 is pressed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 on the mode, and when button3 is pressed somewhere in the list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 TOGGLE is used as the toggle function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (let (el place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (add-elt #'(lambda (elt sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (cond ((null after) ; add to front
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (set sym (cons elt (symbol-value sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ((and (not (eq after t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq place (memq (assq after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (symbol-value sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (symbol-value sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq elt (cons elt (cdr place)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setcdr place elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (set sym (append (symbol-value sym) (list elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (symbol-value sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 toggle-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if toggle-fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (if (not (commandp toggle-fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (error "not an interactive function: %S" toggle-fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (commandp toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq toggle-fun toggle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (if (and toggle-fun name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq toggle-keymap (make-sparse-keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (intern (concat "modeline-minor-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (symbol-name toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "-map"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (define-key toggle-keymap 'button2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; defeat the DUMB-ASS byte-compiler, which tries to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; expand the macro at compile time and fucks up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (eval '(make-modeline-command-wrapper toggle-fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (put toggle 'modeline-toggle-function toggle-fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (and name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let ((hacked-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if toggle-keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (cons (let ((extent (make-extent nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (set-extent-keymap extent toggle-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (set-extent-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 extent 'help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (concat "button2 turns off "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (symbolp toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (symbol-name toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (symbol-name toggle))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 modeline-mousable-minor-mode-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (setq el (assq toggle minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setcdr el (list hacked-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (funcall add-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (list toggle hacked-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 'minor-mode-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (and keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (if (setq el (assq toggle minor-mode-map-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setcdr el keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (funcall add-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (cons toggle keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 'minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (add-minor-mode 'abbrev-mode " Abbrev")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (add-minor-mode 'overwrite-mode 'overwrite-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (add-minor-mode 'auto-fill-function " Fill" nil nil 'auto-fill-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; not really a minor mode...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (add-minor-mode 'defining-kbd-macro " Def")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun modeline-minor-mode-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (popup-menu-and-execute-in-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (cons (format "Minor Mode Commands for %S:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (buffer-name (event-buffer event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (apply 'nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let* ((toggle-sym (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (toggle-fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (or (get toggle-sym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 'modeline-toggle-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (and (fboundp toggle-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (commandp toggle-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 toggle-sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (if (not toggle-fun) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (list (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (concat (if (and (boundp toggle-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (symbol-value toggle-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "turn off " "turn on ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (if (symbolp toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (symbol-name toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (symbol-name toggle-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 toggle-fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defvar modeline-minor-mode-map (make-sparse-keymap 'modeline-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Keymap consulted for mouse-clicks on the minor-mode modeline list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (define-key modeline-minor-mode-map 'button3 'modeline-minor-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defvar modeline-minor-mode-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Extent covering the minor mode modeline strings.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (set-extent-face modeline-minor-mode-extent 'modeline-mousable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (set-extent-keymap modeline-minor-mode-extent modeline-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;; Other ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defun modeline-buffers-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (popup-menu-and-execute-in-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 '("Buffers Popup Menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 :filter buffers-menu-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ["List All Buffers" list-buffers t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "--"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (defvar modeline-buffer-id-left-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (make-sparse-keymap 'modeline-buffer-id-left-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Keymap consulted for mouse-clicks on the left half of the buffer-id string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (defvar modeline-buffer-id-right-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (make-sparse-keymap 'modeline-buffer-id-right-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "Keymap consulted for mouse-clicks on the right half of the buffer-id string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (define-key modeline-buffer-id-left-map 'button2 'mouse-unbury-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (define-key modeline-buffer-id-right-map 'button2 'mouse-bury-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (define-key modeline-buffer-id-left-map 'button3 'modeline-buffers-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (define-key modeline-buffer-id-right-map 'button3 'modeline-buffers-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (make-face 'modeline-buffer-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "Face for the buffer ID string in the modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defvar modeline-buffer-id-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Extent covering the whole of the buffer-id string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (set-extent-face modeline-buffer-id-extent 'modeline-buffer-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defvar modeline-buffer-id-left-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "Extent covering the left half of the buffer-id string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (set-extent-keymap modeline-buffer-id-left-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 modeline-buffer-id-left-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-extent-property modeline-buffer-id-left-extent 'help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "button2 cycles to the previous buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defvar modeline-buffer-id-right-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "Extent covering the right half of the buffer-id string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (set-extent-keymap modeline-buffer-id-right-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 modeline-buffer-id-right-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (set-extent-property modeline-buffer-id-right-extent 'help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "button2 cycles to the next buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defconst modeline-buffer-identification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (list (cons modeline-buffer-id-left-extent (purecopy "XEmacs:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (cons modeline-buffer-id-right-extent (purecopy " %17b")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "Modeline control for identifying the buffer being displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 Its default value is \"XEmacs: %17b\" (NOT!). Major modes that edit things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 other than ordinary files may change this (e.g. Info, Dired,...)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (make-variable-buffer-local 'modeline-buffer-identification)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defconst modeline-process nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Modeline control for displaying info on process status.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 Normally nil in most modes, since there is no process to display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (make-variable-buffer-local 'modeline-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defvar modeline-modified-map (make-sparse-keymap 'modeline-modified-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Keymap consulted for mouse-clicks on the modeline-modified string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (define-key modeline-modified-map 'button2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (make-modeline-command-wrapper 'toggle-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defvar modeline-modified-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "Extent covering the modeline-modified string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (set-extent-face modeline-modified-extent 'modeline-mousable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (set-extent-keymap modeline-modified-extent modeline-modified-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (set-extent-property modeline-modified-extent 'help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "button2 toggles the buffer's read-only status")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defconst modeline-modified (purecopy '("--%1*%1+-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "Modeline control for displaying whether current buffer is modified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (make-variable-buffer-local 'modeline-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defvar modeline-narrowed-map (make-sparse-keymap 'modeline-narrowed-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Keymap consulted for mouse-clicks on the modeline-narrowed string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (define-key modeline-narrowed-map 'button2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (make-modeline-command-wrapper 'widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defvar modeline-narrowed-extent (make-extent nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 "Extent covering the modeline-narrowed string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (set-extent-face modeline-narrowed-extent 'modeline-mousable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (set-extent-keymap modeline-narrowed-extent modeline-narrowed-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (set-extent-property modeline-narrowed-extent 'help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 "button2 widens the buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (setq-default modeline-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (list (purecopy "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (cons modeline-modified-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 'modeline-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (cons modeline-buffer-id-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 'modeline-buffer-identification)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (purecopy " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 'global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (purecopy " %[(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (cons modeline-minor-mode-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (list "" 'mode-name 'minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (cons modeline-narrowed-extent "%n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 'modeline-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (purecopy ")%]----")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (purecopy '(line-number-mode "L%l--"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (purecopy '(-3 . "%p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (purecopy "-%-")))