428
|
1 ;;; modeline.el --- modeline hackery.
|
|
2
|
|
3 ;; Copyright (C) 1988, 1992-1994, 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995, 1996 Ben Wing.
|
|
5
|
|
6 ;; Maintainer: XEmacs Development Team
|
|
7 ;; Keywords: extensions, dumped
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
|
15
|
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
438
|
22 ;; along with XEmacs; see the file COPYING. If not, write to the
|
428
|
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
24 ;; Boston, MA 02111-1307, USA.
|
|
25
|
|
26 ;;; Synched up with: Not in FSF.
|
|
27
|
|
28 ;;; Commentary:
|
|
29
|
|
30 ;; This file is dumped with XEmacs.
|
|
31
|
|
32 ;;; Code:
|
|
33
|
|
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
35 ;;; General mouse modeline stuff ;;;
|
|
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
37
|
|
38 (defgroup modeline nil
|
|
39 "Modeline customizations."
|
|
40 :group 'environment)
|
|
41
|
|
42 (defcustom drag-divider-event-lag 150
|
|
43 "*The pause (in msecs) between divider drag events before redisplaying.
|
|
44 If this value is too small, dragging will be choppy because redisplay cannot
|
|
45 keep up. If it is too large, dragging will be choppy because of the explicit
|
|
46 redisplay delay specified."
|
|
47 :type 'integer
|
|
48 ;; #### Fix group.
|
|
49 :group 'modeline)
|
|
50
|
|
51 (define-obsolete-variable-alias
|
|
52 'drag-modeline-event-lag
|
|
53 'drag-divider-event-lag)
|
|
54
|
|
55 (defcustom modeline-click-swaps-buffers nil
|
|
56 "*If non-nil, clicking on the modeline changes the current buffer.
|
|
57 Click on the left half of the modeline cycles forward through the
|
|
58 buffer list and clicking on the right half cycles backward."
|
|
59 :type 'boolean
|
|
60 :group 'modeline)
|
|
61
|
438
|
62 (defcustom modeline-scrolling-method nil
|
|
63 "*If non-nil, dragging the modeline with the mouse may also scroll its
|
|
64 text horizontally (vertical motion controls window resizing and horizontal
|
|
65 motion controls modeline scrolling).
|
|
66
|
|
67 With a value of t, the modeline text is scrolled in the same direction as
|
|
68 the mouse motion. With a value of 'scrollbar, the modeline is considered as
|
|
69 a scrollbar for its own text, which then moves in the opposite direction."
|
|
70 :type '(choice (const :tag "none" nil)
|
|
71 (const :tag "text" t)
|
|
72 (const :tag "scrollbar" scrollbar))
|
|
73 :set (lambda (sym val)
|
|
74 (set-default sym val)
|
|
75 (when (featurep 'x)
|
|
76 (cond ((eq val t)
|
|
77 (set-glyph-image modeline-pointer-glyph "hand2" 'global 'x))
|
|
78 ((eq val 'scrollbar)
|
|
79 (set-glyph-image modeline-pointer-glyph "fleur" 'global 'x))
|
|
80 (t
|
|
81 (set-glyph-image modeline-pointer-glyph "sb_v_double_arrow"
|
|
82 'global 'x)))))
|
|
83 :group 'modeline)
|
|
84
|
428
|
85 (defun mouse-drag-modeline (event)
|
|
86 "Resize a window by dragging its modeline.
|
|
87 This command should be bound to a button-press event in modeline-map.
|
|
88 Holding down a mouse button and moving the mouse up and down will
|
438
|
89 make the clicked-on window taller or shorter.
|
|
90
|
|
91 See also the variable `modeline-scrolling-method'."
|
428
|
92 (interactive "e")
|
|
93 (or (button-press-event-p event)
|
|
94 (error "%s must be invoked by a mouse-press" this-command))
|
|
95 (or (event-over-modeline-p event)
|
|
96 (error "not over a modeline"))
|
|
97 ;; Give the modeline a "pressed" look. --hniksic
|
|
98 (let-specifier ((modeline-shadow-thickness
|
|
99 (- (specifier-instance modeline-shadow-thickness
|
|
100 (event-window event)))
|
|
101 (event-window event)))
|
|
102 (let ((done nil)
|
|
103 (depress-line (event-y event))
|
|
104 (start-event-frame (event-frame event))
|
|
105 (start-event-window (event-window event))
|
|
106 (start-nwindows (count-windows t))
|
438
|
107 (hscroll-delta (face-width 'modeline))
|
|
108 (start-hscroll (modeline-hscroll (event-window event)))
|
|
109 (start-x-pixel (event-x-pixel event))
|
428
|
110 (last-timestamp 0)
|
|
111 default-line-height
|
|
112 modeline-height
|
|
113 should-enlarge-minibuffer
|
|
114 event min-height minibuffer y top bot edges wconfig growth)
|
|
115 (setq minibuffer (minibuffer-window start-event-frame)
|
|
116 default-line-height (face-height 'default start-event-window)
|
|
117 min-height (+ (* window-min-height default-line-height)
|
|
118 ;; Don't let the window shrink by a
|
|
119 ;; non-multiple of the default line
|
|
120 ;; height. (enlarge-window -1) will do
|
|
121 ;; this if the difference between the
|
|
122 ;; current window height and the minimum
|
|
123 ;; window height is less than the height
|
|
124 ;; of the default font. These extra
|
|
125 ;; lost pixels of height don't come back
|
|
126 ;; if you grow the window again. This
|
|
127 ;; can make it impossible to drag back
|
|
128 ;; to the exact original size, which is
|
|
129 ;; disconcerting.
|
|
130 (% (window-pixel-height start-event-window)
|
|
131 default-line-height))
|
|
132 modeline-height
|
|
133 (if (specifier-instance has-modeline-p start-event-window)
|
|
134 (+ (face-height 'modeline start-event-window)
|
|
135 (* 2 (specifier-instance modeline-shadow-thickness
|
|
136 start-event-window)))
|
|
137 (* 2 (specifier-instance modeline-shadow-thickness
|
|
138 start-event-window))))
|
|
139 (if (not (eq (window-frame minibuffer) start-event-frame))
|
|
140 (setq minibuffer nil))
|
|
141 (if (and (null minibuffer) (one-window-p t))
|
|
142 (error "Attempt to resize sole window"))
|
|
143 ;; if this is the bottommost ordinary window, then to
|
|
144 ;; move its modeline the minibuffer must be enlarged.
|
|
145 (setq should-enlarge-minibuffer
|
|
146 (and minibuffer (window-lowest-p start-event-window)))
|
|
147 ;; loop reading events
|
|
148 (while (not done)
|
|
149 (setq event (next-event event))
|
|
150 ;; requeue event and quit if this is a misc-user, eval or
|
|
151 ;; keypress event.
|
|
152 ;; quit if this is a button press or release event, or if the event
|
|
153 ;; occurred in some other frame.
|
|
154 ;; drag if this is a mouse motion event and the time
|
|
155 ;; between this event and the last event is greater than
|
|
156 ;; drag-divider-event-lag.
|
|
157 ;; do nothing if this is any other kind of event.
|
|
158 (cond ((or (misc-user-event-p event)
|
|
159 (key-press-event-p event))
|
|
160 (setq unread-command-events (nconc unread-command-events
|
|
161 (list event))
|
|
162 done t))
|
|
163 ((button-release-event-p event)
|
|
164 (setq done t)
|
|
165 ;; Consider we have a mouse click neither X pos (modeline
|
|
166 ;; scroll) nore Y pos (modeline drag) have changed.
|
|
167 (and modeline-click-swaps-buffers
|
|
168 (= depress-line (event-y event))
|
438
|
169 (or (not modeline-scrolling-method)
|
|
170 (= start-hscroll
|
|
171 (modeline-hscroll start-event-window)))
|
428
|
172 (modeline-swap-buffers event)))
|
|
173 ((button-event-p event)
|
|
174 (setq done t))
|
|
175 ((not (motion-event-p event))
|
|
176 (dispatch-event event))
|
|
177 ((not (eq start-event-frame (event-frame event)))
|
|
178 (setq done t))
|
|
179 ((< (abs (- (event-timestamp event) last-timestamp))
|
|
180 drag-divider-event-lag)
|
|
181 nil)
|
|
182 (t
|
438
|
183 (when modeline-scrolling-method
|
|
184 (let ((delta (/ (- (event-x-pixel event) start-x-pixel)
|
|
185 hscroll-delta)))
|
|
186 (set-modeline-hscroll start-event-window
|
|
187 (if (eq modeline-scrolling-method t)
|
|
188 (- start-hscroll delta)
|
|
189 (+ start-hscroll delta)))
|
|
190 ))
|
428
|
191 (setq last-timestamp (event-timestamp event)
|
|
192 y (event-y-pixel event)
|
|
193 edges (window-pixel-edges start-event-window)
|
|
194 top (nth 1 edges)
|
|
195 bot (nth 3 edges))
|
|
196 ;; scale back a move that would make the
|
|
197 ;; window too short.
|
|
198 (cond ((< (- y top (- modeline-height)) min-height)
|
|
199 (setq y (+ top min-height (- modeline-height)))))
|
|
200 ;; compute size change needed
|
|
201 (setq growth (- y bot (/ (- modeline-height) 2))
|
|
202 wconfig (current-window-configuration))
|
|
203 ;; grow/shrink minibuffer?
|
|
204 (if should-enlarge-minibuffer
|
|
205 (progn
|
|
206 ;; yes. scale back shrinkage if it
|
|
207 ;; would make the minibuffer less than 1
|
|
208 ;; line tall.
|
|
209 ;;
|
|
210 ;; also flip the sign of the computed growth,
|
|
211 ;; since if we want to grow the window with the
|
|
212 ;; modeline we need to shrink the minibuffer
|
|
213 ;; and vice versa.
|
|
214 (if (and (> growth 0)
|
|
215 (< (- (window-pixel-height minibuffer)
|
|
216 growth)
|
|
217 default-line-height))
|
|
218 (setq growth
|
|
219 (- (window-pixel-height minibuffer)
|
|
220 default-line-height)))
|
|
221 (setq growth (- growth))))
|
|
222 ;; window grow and shrink by lines not pixels, so
|
|
223 ;; divide the pixel height by the height of the
|
|
224 ;; default face.
|
|
225 (setq growth (/ growth default-line-height))
|
|
226 ;; grow/shrink the window
|
|
227 (enlarge-window growth nil (if should-enlarge-minibuffer
|
|
228 minibuffer
|
|
229 start-event-window))
|
|
230 ;; if this window's growth caused another
|
|
231 ;; window to be deleted because it was too
|
|
232 ;; short, rescind the change.
|
|
233 ;;
|
|
234 ;; if size change caused space to be stolen
|
|
235 ;; from a window above this one, rescind the
|
|
236 ;; change, but only if we didn't grow/shrink
|
|
237 ;; the minibuffer. minibuffer size changes
|
|
238 ;; can cause all windows to shrink... no way
|
|
239 ;; around it.
|
|
240 (if (or (/= start-nwindows (count-windows t))
|
|
241 (and (not should-enlarge-minibuffer)
|
|
242 (/= top (nth 1 (window-pixel-edges
|
|
243 start-event-window)))))
|
|
244 (set-window-configuration wconfig))))))))
|
|
245
|
|
246 ;; from Bob Weiner (bob_weiner@pts.mot.com)
|
|
247 ;; Whether this function should be called is now decided in
|
|
248 ;; mouse-drag-modeline - dverna feb. 98
|
|
249 (defun modeline-swap-buffers (event)
|
|
250 "Handle mouse clicks on modeline by switching buffers.
|
|
251 If click on left half of a frame's modeline, bury current buffer.
|
|
252 If click on right half of a frame's modeline, raise bottommost buffer.
|
|
253 Arg EVENT is the button release event that occurred on the modeline."
|
|
254 (or (event-over-modeline-p event)
|
|
255 (error "not over a modeline"))
|
|
256 (or (button-release-event-p event)
|
|
257 (error "not a button release event"))
|
|
258 (if (< (event-x event) (/ (window-width (event-window event)) 2))
|
|
259 ;; On left half of modeline, bury current buffer,
|
|
260 ;; displaying second buffer on list.
|
|
261 (mouse-bury-buffer event)
|
|
262 ;; On right half of modeline, raise and display bottommost
|
|
263 ;; buffer in buffer list.
|
|
264 (mouse-unbury-buffer event)))
|
|
265
|
|
266 (defconst modeline-menu
|
|
267 '("Window Commands"
|
|
268 ["Delete Window Above" delete-window t]
|
|
269 ["Delete Other Windows" delete-other-windows t]
|
|
270 ["Split Window Above" split-window-vertically t]
|
|
271 ["Split Window Horizontally" split-window-horizontally t]
|
|
272 ["Balance Windows" balance-windows t]
|
|
273 ))
|
|
274
|
|
275 (defun modeline-menu (event)
|
|
276 (interactive "e")
|
|
277 (popup-menu-and-execute-in-window
|
|
278 (cons (format "Window Commands for %S:"
|
|
279 (buffer-name (event-buffer event)))
|
|
280 (cdr modeline-menu))
|
|
281 event))
|
|
282
|
|
283 (defvar modeline-map (make-sparse-keymap 'modeline-map)
|
|
284 "Keymap consulted for mouse-clicks on the modeline of a window.
|
|
285 This variable may be buffer-local; its value will be looked up in
|
|
286 the buffer of the window whose modeline was clicked upon.")
|
|
287
|
|
288 (define-key modeline-map 'button1 'mouse-drag-modeline)
|
|
289 ;; button2 selects the window without setting point
|
|
290 (define-key modeline-map 'button2 (lambda () (interactive "@")))
|
|
291 (define-key modeline-map 'button3 'modeline-menu)
|
|
292
|
|
293 (make-face 'modeline-mousable "Face for mousable portions of the modeline.")
|
|
294 (set-face-parent 'modeline-mousable 'modeline nil '(default))
|
|
295 (when (featurep 'window-system)
|
440
|
296 (set-face-foreground 'modeline-mousable "firebrick" nil '(default color win))
|
|
297 (set-face-font 'modeline-mousable [bold] nil '(default mono win))
|
|
298 (set-face-font 'modeline-mousable [bold] nil '(default grayscale win)))
|
428
|
299
|
|
300 (defmacro make-modeline-command-wrapper (command)
|
|
301 `#'(lambda (event)
|
|
302 (interactive "e")
|
|
303 (save-selected-window
|
|
304 (select-window (event-window event))
|
|
305 (call-interactively ',(eval command)))))
|
|
306
|
|
307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
308 ;;; Minor modes ;;;
|
|
309 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
310
|
|
311 (defvar minor-mode-alist nil
|
|
312 "Alist saying how to show minor modes in the modeline.
|
|
313 Each element looks like (VARIABLE STRING);
|
|
314 STRING is included in the modeline iff VARIABLE's value is non-nil.
|
|
315
|
|
316 Actually, STRING need not be a string; any possible modeline element
|
|
317 is okay. See `modeline-format'.")
|
|
318
|
|
319 ;; Used by C code (lookup-key and friends) but defined here.
|
|
320 (defvar minor-mode-map-alist nil
|
|
321 "Alist of keymaps to use for minor modes.
|
|
322 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
|
|
323 key sequences and look up bindings iff VARIABLE's value is non-nil.
|
|
324 If two active keymaps bind the same key, the keymap appearing earlier
|
|
325 in the list takes precedence.")
|
|
326
|
|
327 (make-face 'modeline-mousable-minor-mode
|
|
328 "Face for mousable minor-mode strings in the modeline.")
|
|
329 (set-face-parent 'modeline-mousable-minor-mode 'modeline-mousable nil
|
|
330 '(default))
|
|
331 (when (featurep 'window-system)
|
440
|
332 (set-face-foreground 'modeline-mousable-minor-mode '("green4" "forestgreen")
|
|
333 nil '(default color win)))
|
428
|
334
|
|
335 (defvar modeline-mousable-minor-mode-extent (make-extent nil nil)
|
|
336 ;; alliteration at its finest.
|
|
337 "Extent managing the mousable minor mode modeline strings.")
|
|
338 (set-extent-face modeline-mousable-minor-mode-extent
|
|
339 'modeline-mousable-minor-mode)
|
|
340
|
|
341 ;; This replaces the idiom
|
|
342 ;;
|
|
343 ;; (or (assq 'isearch-mode minor-mode-alist)
|
|
344 ;; (setq minor-mode-alist
|
|
345 ;; (purecopy
|
|
346 ;; (append minor-mode-alist
|
|
347 ;; '((isearch-mode isearch-mode))))))
|
|
348
|
|
349 (defun add-minor-mode (toggle name &optional keymap after toggle-fun)
|
|
350 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
|
|
351
|
|
352 TOGGLE is a symbol whose value as a variable specifies whether the
|
|
353 minor mode is active.
|
|
354
|
|
355 NAME is the name that should appear in the modeline. It should either
|
|
356 be a string beginning with a space, or a symbol with a similar string
|
|
357 as its value.
|
|
358
|
|
359 KEYMAP is a keymap to make active when the minor mode is active.
|
|
360
|
|
361 AFTER is the toggling symbol used for another minor mode. If AFTER is
|
|
362 non-nil, then it is used to position the new mode in the minor-mode
|
|
363 alists.
|
|
364
|
|
365 TOGGLE-FUN specifies an interactive function that is called to toggle
|
|
366 the mode on and off; this affects what happens when button2 is pressed
|
|
367 on the mode, and when button3 is pressed somewhere in the list of
|
|
368 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
|
|
369 TOGGLE is used as the toggle function.
|
|
370
|
|
371 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
|
|
372 (let* ((add-elt #'(lambda (elt sym)
|
|
373 (let (place)
|
|
374 (cond ((null after) ; add to front
|
|
375 (push elt (symbol-value sym)))
|
|
376 ((and (not (eq after t))
|
|
377 (setq place (memq (assq after
|
|
378 (symbol-value sym))
|
|
379 (symbol-value sym))))
|
|
380 (push elt (cdr place)))
|
|
381 (t
|
|
382 (set sym (append (symbol-value sym)
|
|
383 (list elt))))))
|
|
384 (symbol-value sym)))
|
|
385 el toggle-keymap)
|
|
386 (if toggle-fun
|
|
387 (check-argument-type 'commandp toggle-fun)
|
|
388 (when (commandp toggle)
|
|
389 (setq toggle-fun toggle)))
|
|
390 (when (and toggle-fun name)
|
|
391 (setq toggle-keymap (make-sparse-keymap
|
|
392 (intern (concat "modeline-minor-"
|
|
393 (symbol-name toggle)
|
|
394 "-map"))))
|
|
395 (define-key toggle-keymap 'button2
|
|
396 ;; defeat the DUMB-ASS byte-compiler, which tries to
|
|
397 ;; expand the macro at compile time and fucks up.
|
|
398 (eval '(make-modeline-command-wrapper toggle-fun)))
|
|
399 (put toggle 'modeline-toggle-function toggle-fun))
|
|
400 (when name
|
|
401 (let ((hacked-name
|
|
402 (if toggle-keymap
|
|
403 (cons (let ((extent (make-extent nil nil)))
|
|
404 (set-extent-keymap extent toggle-keymap)
|
|
405 (set-extent-property
|
|
406 extent 'help-echo
|
|
407 (concat "button2 turns off "
|
|
408 (if (symbolp toggle-fun)
|
|
409 (symbol-name toggle-fun)
|
|
410 (symbol-name toggle))))
|
|
411 extent)
|
|
412 (cons modeline-mousable-minor-mode-extent name))
|
|
413 name)))
|
|
414 (if (setq el (assq toggle minor-mode-alist))
|
|
415 (setcdr el (list hacked-name))
|
438
|
416 (funcall add-elt
|
428
|
417 (list toggle hacked-name)
|
|
418 'minor-mode-alist))))
|
|
419 (when keymap
|
|
420 (if (setq el (assq toggle minor-mode-map-alist))
|
|
421 (setcdr el keymap)
|
|
422 (funcall add-elt
|
|
423 (cons toggle keymap)
|
|
424 'minor-mode-map-alist)))))
|
|
425
|
|
426 ;; #### TODO: Add `:menu-tag' keyword to add-minor-mode. Or create a
|
|
427 ;; separate function to manage the minor mode menu.
|
|
428
|
|
429 ;(put 'abbrev-mode :menu-tag "Abbreviation Expansion")
|
|
430 (add-minor-mode 'abbrev-mode " Abbrev")
|
|
431 ;; only when visiting a file...
|
|
432 (add-minor-mode 'overwrite-mode 'overwrite-mode)
|
|
433 ;(put 'auto-fill-function :menu-tag "Auto Fill")
|
|
434 (add-minor-mode 'auto-fill-function " Fill" nil nil 'auto-fill-mode)
|
|
435
|
|
436 ;(put 'defining-kbd-macro :menu-tag "Keyboard Macro")
|
|
437 (add-minor-mode 'defining-kbd-macro " Def" nil nil
|
|
438 (lambda ()
|
|
439 (interactive)
|
|
440 (if defining-kbd-macro
|
|
441 (progn
|
|
442 ;; #### This means to disregard the last event.
|
|
443 ;; It is needed because the last recorded
|
|
444 ;; event is usually the mouse event that
|
|
445 ;; invoked the menu item (and this function),
|
|
446 ;; and having it in the macro causes problems.
|
|
447 (zap-last-kbd-macro-event)
|
|
448 (end-kbd-macro nil))
|
|
449 (start-kbd-macro nil))))
|
|
450
|
|
451 (defun modeline-minor-mode-menu (event)
|
|
452 "The menu that pops up when you press `button3' inside the
|
|
453 parentheses on the modeline."
|
|
454 (interactive "e")
|
|
455 (save-excursion
|
|
456 (set-buffer (event-buffer event))
|
|
457 (popup-menu-and-execute-in-window
|
|
458 (cons
|
|
459 "Minor Mode Toggles"
|
|
460 (sort
|
|
461 (delq nil (mapcar
|
|
462 #'(lambda (x)
|
|
463 (let* ((toggle-sym (car x))
|
|
464 (toggle-fun (or (get toggle-sym
|
|
465 'modeline-toggle-function)
|
|
466 (and (commandp toggle-sym)
|
|
467 toggle-sym)))
|
|
468 (menu-tag (symbol-name (if (symbolp toggle-fun)
|
|
469 toggle-fun
|
|
470 toggle-sym))
|
|
471 ;; Here a function should
|
|
472 ;; maybe be invoked to
|
|
473 ;; beautify the symbol's
|
|
474 ;; menu appearance.
|
|
475 ))
|
|
476 (and toggle-fun
|
|
477 (vector menu-tag
|
|
478 toggle-fun
|
|
479 ;; The following two are wrong
|
|
480 ;; because of possible name
|
|
481 ;; clashes.
|
|
482 ;:active (get toggle-sym :active t)
|
|
483 ;:included (get toggle-sym :included t)
|
|
484 :style 'toggle
|
|
485 :selected (and (boundp toggle-sym)
|
|
486 toggle-sym)))))
|
|
487 minor-mode-alist))
|
|
488 (lambda (e1 e2)
|
|
489 (string< (aref e1 0) (aref e2 0)))))
|
|
490 event)))
|
|
491
|
|
492 (defvar modeline-minor-mode-map (make-sparse-keymap 'modeline-minor-mode-map)
|
|
493 "Keymap consulted for mouse-clicks on the minor-mode modeline list.")
|
|
494 (define-key modeline-minor-mode-map 'button3 'modeline-minor-mode-menu)
|
|
495
|
|
496 (defvar modeline-minor-mode-extent (make-extent nil nil)
|
|
497 "Extent covering the minor mode modeline strings.")
|
|
498 (set-extent-face modeline-minor-mode-extent 'modeline-mousable)
|
|
499 (set-extent-keymap modeline-minor-mode-extent modeline-minor-mode-map)
|
|
500
|
|
501
|
|
502 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
503 ;;; Other ;;;
|
|
504 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
505
|
|
506 (defun modeline-buffers-menu (event)
|
|
507 (interactive "e")
|
|
508 (popup-menu-and-execute-in-window
|
|
509 '("Buffers Popup Menu"
|
|
510 :filter buffers-menu-filter
|
|
511 ["List All Buffers" list-buffers t]
|
|
512 "--"
|
|
513 )
|
|
514 event))
|
|
515
|
|
516 (defvar modeline-buffer-id-left-map
|
|
517 (make-sparse-keymap 'modeline-buffer-id-left-map)
|
|
518 "Keymap consulted for mouse-clicks on the left half of the buffer-id string.")
|
|
519
|
|
520 (defvar modeline-buffer-id-right-map
|
|
521 (make-sparse-keymap 'modeline-buffer-id-right-map)
|
|
522 "Keymap consulted for mouse-clicks on the right half of the buffer-id string.")
|
|
523
|
|
524 (define-key modeline-buffer-id-left-map 'button2 'mouse-unbury-buffer)
|
|
525 (define-key modeline-buffer-id-right-map 'button2 'mouse-bury-buffer)
|
|
526 (define-key modeline-buffer-id-left-map 'button3 'modeline-buffers-menu)
|
|
527 (define-key modeline-buffer-id-right-map 'button3 'modeline-buffers-menu)
|
|
528
|
|
529 (make-face 'modeline-buffer-id
|
|
530 "Face for the buffer ID string in the modeline.")
|
|
531 (set-face-parent 'modeline-buffer-id 'modeline nil '(default))
|
|
532 (when (featurep 'window-system)
|
440
|
533 (set-face-foreground 'modeline-buffer-id "blue4" nil '(default color win))
|
|
534 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default mono win))
|
|
535 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default grayscale win)))
|
428
|
536 (when (featurep 'tty)
|
|
537 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default tty)))
|
|
538
|
|
539 (defvar modeline-buffer-id-extent (make-extent nil nil)
|
|
540 "Extent covering the whole of the buffer-id string.")
|
|
541 (set-extent-face modeline-buffer-id-extent 'modeline-buffer-id)
|
438
|
542
|
428
|
543 (defvar modeline-buffer-id-left-extent (make-extent nil nil)
|
|
544 "Extent covering the left half of the buffer-id string.")
|
|
545 (set-extent-keymap modeline-buffer-id-left-extent
|
|
546 modeline-buffer-id-left-map)
|
|
547 (set-extent-property modeline-buffer-id-left-extent 'help-echo
|
|
548 "button2 cycles to the previous buffer")
|
|
549
|
|
550 (defvar modeline-buffer-id-right-extent (make-extent nil nil)
|
|
551 "Extent covering the right half of the buffer-id string.")
|
|
552 (set-extent-keymap modeline-buffer-id-right-extent
|
|
553 modeline-buffer-id-right-map)
|
|
554 (set-extent-property modeline-buffer-id-right-extent 'help-echo
|
|
555 "button2 cycles to the next buffer")
|
|
556
|
|
557 (defconst modeline-buffer-identification
|
|
558 (list (cons modeline-buffer-id-left-extent (purecopy "XEmacs%N:"))
|
|
559 ; this used to be "XEmacs:"
|
|
560 (cons modeline-buffer-id-right-extent (purecopy " %17b")))
|
|
561 "Modeline control for identifying the buffer being displayed.
|
|
562 Its default value is \"XEmacs: %17b\" (NOT!). Major modes that edit things
|
|
563 other than ordinary files may change this (e.g. Info, Dired,...)")
|
|
564 (make-variable-buffer-local 'modeline-buffer-identification)
|
|
565
|
|
566 ;; These are for the sake of minor mode menu. #### All of this is
|
|
567 ;; kind of dirty. `add-minor-mode' started out as a simple substitute
|
|
568 ;; for (or (assq ...) ...) FSF stuff, but now is used for all kind of
|
|
569 ;; stuff. There should perhaps be a separate function to add toggles
|
|
570 ;; to the minor-mode-menu.
|
|
571 (add-minor-mode 'line-number-mode "")
|
|
572 (add-minor-mode 'column-number-mode "")
|
|
573
|
|
574 (defconst modeline-process nil
|
|
575 "Modeline control for displaying info on process status.
|
|
576 Normally nil in most modes, since there is no process to display.")
|
|
577 (make-variable-buffer-local 'modeline-process)
|
|
578
|
|
579 (defvar modeline-modified-map (make-sparse-keymap 'modeline-modified-map)
|
|
580 "Keymap consulted for mouse-clicks on the modeline-modified string.")
|
|
581 (define-key modeline-modified-map 'button2
|
|
582 (make-modeline-command-wrapper 'modeline-toggle-read-only))
|
|
583
|
|
584 (defvar modeline-modified-extent (make-extent nil nil)
|
|
585 "Extent covering the modeline-modified string.")
|
|
586 (set-extent-face modeline-modified-extent 'modeline-mousable)
|
|
587 (set-extent-keymap modeline-modified-extent modeline-modified-map)
|
|
588 (set-extent-property modeline-modified-extent 'help-echo
|
|
589 "button2 toggles the buffer's read-only status")
|
|
590
|
|
591 (defconst modeline-modified (purecopy '("--%1*%1+-"))
|
|
592 "Modeline control for displaying whether current buffer is modified.")
|
|
593 (make-variable-buffer-local 'modeline-modified)
|
|
594
|
|
595 (defvar modeline-narrowed-map (make-sparse-keymap 'modeline-narrowed-map)
|
|
596 "Keymap consulted for mouse-clicks on the modeline-narrowed string.")
|
|
597 (define-key modeline-narrowed-map 'button2
|
|
598 (make-modeline-command-wrapper 'widen))
|
|
599
|
|
600 (defvar modeline-narrowed-extent (make-extent nil nil)
|
|
601 "Extent covering the modeline-narrowed string.")
|
|
602 (set-extent-face modeline-narrowed-extent 'modeline-mousable)
|
|
603 (set-extent-keymap modeline-narrowed-extent modeline-narrowed-map)
|
|
604 (set-extent-property modeline-narrowed-extent 'help-echo
|
|
605 "button2 widens the buffer")
|
|
606
|
|
607 (setq-default
|
|
608 modeline-format
|
|
609 (list
|
|
610 (purecopy "")
|
|
611 (cons modeline-modified-extent 'modeline-modified)
|
|
612 (cons modeline-buffer-id-extent 'modeline-buffer-identification)
|
|
613 (purecopy " ")
|
|
614 'global-mode-string
|
|
615 (purecopy " %[(")
|
|
616 (cons modeline-minor-mode-extent
|
|
617 (list (purecopy "") 'mode-name 'minor-mode-alist))
|
|
618 (cons modeline-narrowed-extent (purecopy "%n"))
|
|
619 'modeline-process
|
|
620 (purecopy ")%]----")
|
|
621 (list 'line-number-mode (purecopy "L%l--"))
|
|
622 (list 'column-number-mode (purecopy "C%c--"))
|
|
623 (cons -3 (purecopy "%p"))
|
|
624 (purecopy "-%-")))
|
|
625
|
|
626 ;;; Added for XEmacs 20.3. Provide wrapper for vc since it may not always be
|
|
627 ;;; present, and its symbols are not visible this early in the dump if it
|
|
628 ;;; is.
|
|
629
|
|
630 (defun modeline-toggle-read-only ()
|
|
631 "Change whether this buffer is visiting its file read-only.
|
|
632 With arg, set read-only iff arg is positive.
|
|
633 This function is designed to be called when the read-only indicator on the
|
|
634 modeline is clicked. It will call `vc-toggle-read-only' if available,
|
|
635 otherwise it will call the usual `toggle-read-only'."
|
|
636 (interactive)
|
|
637 (if (fboundp 'vc-toggle-read-only)
|
|
638 (vc-toggle-read-only)
|
|
639 (toggle-read-only)))
|
|
640
|
|
641 ;;; modeline.el ends here
|