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