annotate lisp/modeline.el @ 398:74fd4e045ea6 r21-2-29

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