annotate lisp/modeline.el @ 265:8efd647ea9ca r20-5b31

Import from CVS: tag r20-5b31
author cvs
date Mon, 13 Aug 2007 10:25:37 +0200
parents 727739f917cb
children 7df0dd720c89
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
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
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
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 (defcustom drag-modeline-event-lag 150
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 "*The pause (in msecs) between drag modeline events before redisplaying.
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
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 :group 'modeline)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 (defcustom modeline-click-swaps-buffers nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 "*If non-nil, clicking on the modeline changes the current buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 Click on the left half of the modeline cycles forward through the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 buffer list and clicking on the right half cycles backward."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55 :group 'modeline)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 (defun mouse-drag-modeline (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 "Resize a window by dragging its modeline.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 This command should be bound to a button-press event in modeline-map.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 Holding down a mouse button and moving the mouse up and down will
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 make the clicked-on window taller or shorter."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 (or (button-press-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 (error "%s must be invoked by a mouse-press" this-command))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 (or (event-over-modeline-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 (error "not over a modeline"))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
67 ;; Give the modeline a "pressed" look. --hniksic
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
68 (letf (((specifier-instance modeline-shadow-thickness
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
69 (event-window event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
70 (- (specifier-instance modeline-shadow-thickness
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
71 (event-window event)))))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
72 (let ((done nil)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
73 (depress-line (event-y event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
74 (start-event-frame (event-frame event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
75 (start-event-window (event-window event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
76 (start-nwindows (count-windows t))
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
77 (hscroll-delta (face-width 'modeline))
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
78 ;; (start-hscroll (modeline-hscroll (event-window event)))
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
79 (start-x-pixel (event-x-pixel event))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
80 (last-timestamp 0)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
81 default-line-height
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 modeline-height
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
83 should-enlarge-minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
84 event min-height minibuffer y top bot edges wconfig growth)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
85 (setq minibuffer (minibuffer-window start-event-frame)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
86 default-line-height (face-height 'default start-event-window)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
87 min-height (+ (* window-min-height default-line-height)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
88 ;; Don't let the window shrink by a
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
89 ;; non-multiple of the default line
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
90 ;; height. (enlarge-window -1) will do
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
91 ;; this if the difference between the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
92 ;; current window height and the minimum
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
93 ;; window height is less than the height
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
94 ;; of the default font. These extra
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
95 ;; lost pixels of height don't come back
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
96 ;; if you grow the window again. This
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
97 ;; can make it impossible to drag back
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
98 ;; to the exact original size, which is
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
99 ;; disconcerting.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
100 (% (window-pixel-height start-event-window)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
101 default-line-height))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
102 modeline-height
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 (if (specifier-instance has-modeline-p start-event-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 (+ (face-height 'modeline start-event-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (* 2 (specifier-instance modeline-shadow-thickness
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 start-event-window)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (* 2 (specifier-instance modeline-shadow-thickness
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 start-event-window))))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
109 (if (not (eq (window-frame minibuffer) start-event-frame))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
110 (setq minibuffer nil))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
111 (if (and (null minibuffer) (one-window-p t))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
112 (error "Attempt to resize sole window"))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
113 ;; if this is the bottommost ordinary window, then to
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
114 ;; move its modeline the minibuffer must be enlarged.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
115 (setq should-enlarge-minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
116 (and minibuffer (window-lowest-p start-event-window)))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
117 ;; loop reading events
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
118 (while (not done)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
119 (setq event (next-event event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
120 ;; requeue event and quit if this is a misc-user, eval or
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
121 ;; keypress event.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
122 ;; 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
123 ;; occurred in some other frame.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
124 ;; drag if this is a mouse motion event and the time
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
125 ;; between this event and the last event is greater than
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
126 ;; drag-modeline-event-lag.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
127 ;; do nothing if this is any other kind of event.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
128 (cond ((or (misc-user-event-p event)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
129 (key-press-event-p event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
130 (setq unread-command-events (nconc unread-command-events
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
131 (list event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
132 done t))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
133 ((button-release-event-p event)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
134 (setq done t)
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
135 ;; Consider we have a mouse click neither X pos (modeline
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
136 ;; scroll) nore Y pos (modeline drag) have changed.
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
137 (and modeline-click-swaps-buffers
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
138 (= depress-line (event-y event))
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
139 ;; (= start-hscroll (modeline-hscroll start-event-window))
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
140 (modeline-swap-buffers event)))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
141 ((button-event-p event)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
142 (setq done t))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
143 ((not (motion-event-p event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
144 (dispatch-event event))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
145 ((not (eq start-event-frame (event-frame event)))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
146 (setq done t))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
147 ((< (abs (- (event-timestamp event) last-timestamp))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
148 drag-modeline-event-lag)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
149 nil)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
150 (t
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
151 ;; (set-modeline-hscroll start-event-window
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
152 ;; (+ (/ (- (event-x-pixel event)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
153 ;; start-x-pixel)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
154 ;; hscroll-delta)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 263
diff changeset
155 ;; start-hscroll))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
156 (setq last-timestamp (event-timestamp event)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
157 y (event-y-pixel event)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
158 edges (window-pixel-edges start-event-window)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
159 top (nth 1 edges)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
160 bot (nth 3 edges))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
161 ;; scale back a move that would make the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
162 ;; window too short.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
163 (cond ((< (- y top (- modeline-height)) min-height)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
164 (setq y (+ top min-height (- modeline-height)))))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
165 ;; compute size change needed
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
166 (setq growth (- y bot (/ (- modeline-height) 2))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
167 wconfig (current-window-configuration))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
168 ;; grow/shrink minibuffer?
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
169 (if should-enlarge-minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
170 (progn
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
171 ;; yes. scale back shrinkage if it
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
172 ;; would make the minibuffer less than 1
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
173 ;; line tall.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
174 ;;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
175 ;; also flip the sign of the computed growth,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
176 ;; since if we want to grow the window with the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
177 ;; modeline we need to shrink the minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
178 ;; and vice versa.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
179 (if (and (> growth 0)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
180 (< (- (window-pixel-height minibuffer)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
181 growth)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
182 default-line-height))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
183 (setq growth
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
184 (- (window-pixel-height minibuffer)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
185 default-line-height)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (setq growth (- growth))))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
187 ;; window grow and shrink by lines not pixels, so
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
188 ;; divide the pixel height by the height of the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
189 ;; default face.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
190 (setq growth (/ growth default-line-height))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
191 ;; grow/shrink the window
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
192 (enlarge-window growth nil (if should-enlarge-minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
193 minibuffer
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
194 start-event-window))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
195 ;; if this window's growth caused another
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
196 ;; window to be deleted because it was too
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
197 ;; short, rescind the change.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
198 ;;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
199 ;; if size change caused space to be stolen
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
200 ;; from a window above this one, rescind the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
201 ;; change, but only if we didn't grow/shrink
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
202 ;; the minibuffer. minibuffer size changes
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
203 ;; can cause all windows to shrink... no way
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
204 ;; around it.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
205 (if (or (/= start-nwindows (count-windows t))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
206 (and (not should-enlarge-minibuffer)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
207 (/= top (nth 1 (window-pixel-edges
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
208 start-event-window)))))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 209
diff changeset
209 (set-window-configuration wconfig))))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 ;; from Bob Weiner (bob_weiner@pts.mot.com)
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
212 ;; Whether this function should be called is now decided in
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
213 ;; mouse-drag-modeline - dverna feb. 98
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
214 (defun modeline-swap-buffers (event)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
215 "Handle mouse clicks on modeline by switching buffers.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 If click on left half of a frame's modeline, bury current buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 If click on right half of a frame's modeline, raise bottommost buffer.
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
218 Arg EVENT is the button release event that occured on the modeline."
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
219 (or (event-over-modeline-p event)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
220 (error "not over a modeline"))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
221 (or (button-release-event-p event)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
222 (error "not a button release event"))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
223 (if (< (event-x event) (/ (window-width (event-window event)) 2))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
224 ;; On left half of modeline, bury current buffer,
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
225 ;; displaying second buffer on list.
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
226 (mouse-bury-buffer event)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
227 ;; On right half of modeline, raise and display bottommost
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
228 ;; buffer in buffer list.
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 257
diff changeset
229 (mouse-unbury-buffer event)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 (defconst modeline-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 '("Window Commands"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 ["Delete Window Above" delete-window t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 ["Delete Other Windows" delete-other-windows t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235 ["Split Window Above" split-window-vertically t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 ["Split Window Horizontally" split-window-horizontally t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237 ["Balance Windows" balance-windows t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 (defun modeline-menu (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (popup-menu-and-execute-in-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 (cons (format "Window Commands for %S:"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (buffer-name (event-buffer event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 (cdr modeline-menu))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 (defvar modeline-map (make-sparse-keymap 'modeline-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249 "Keymap consulted for mouse-clicks on the modeline of a window.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 This variable may be buffer-local; its value will be looked up in
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 the buffer of the window whose modeline was clicked upon.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 (define-key modeline-map 'button1 'mouse-drag-modeline)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 ;; button2 selects the window without setting point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 (define-key modeline-map 'button2 (lambda () (interactive "@")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 (define-key modeline-map 'button3 'modeline-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (make-face 'modeline-mousable "Face for mousable portions of the modeline.")
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
259 (set-face-parent 'modeline-mousable 'modeline nil '(default))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 (when (featurep 'x)
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
261 (set-face-foreground 'modeline-mousable "firebrick" 'global
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
262 '(default color x))
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
263 (set-face-font 'modeline-mousable [bold] nil '(default mono x))
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
264 (set-face-font 'modeline-mousable [bold] nil '(default grayscale x)))
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 (defmacro make-modeline-command-wrapper (command)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 `#'(lambda (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 (save-selected-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 (select-window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 (call-interactively ',(eval command)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 ;;; Minor modes ;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 (defvar minor-mode-alist nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 "Alist saying how to show minor modes in the modeline.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 Each element looks like (VARIABLE STRING);
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 STRING is included in the modeline iff VARIABLE's value is non-nil.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 Actually, STRING need not be a string; any possible modeline element
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 is okay. See `modeline-format'.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 ;; Used by C code (lookup-key and friends) but defined here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 (defvar minor-mode-map-alist nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 "Alist of keymaps to use for minor modes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 key sequences and look up bindings iff VARIABLE's value is non-nil.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290 If two active keymaps bind the same key, the keymap appearing earlier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 in the list takes precedence.")
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-minor-mode
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 "Face for mousable minor-mode strings in the modeline.")
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
295 (set-face-parent 'modeline-mousable-minor-mode 'modeline-mousable nil
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
296 '(default))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 (when (featurep 'x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 (set-face-foreground 'modeline-mousable-minor-mode
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
299 '(((default color x) . "green4")
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
300 ((default color x) . "forestgreen")) 'global))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 (defvar modeline-mousable-minor-mode-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 ;; alliteration at its finest.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 "Extent managing the mousable minor mode modeline strings.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 (set-extent-face modeline-mousable-minor-mode-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 'modeline-mousable-minor-mode)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 ;; This replaces the idiom
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 ;; (or (assq 'isearch-mode minor-mode-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311 ;; (setq minor-mode-alist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 ;; (purecopy
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313 ;; (append minor-mode-alist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 ;; '((isearch-mode isearch-mode))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 (defvar place)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (defun add-minor-mode (toggle name &optional keymap after toggle-fun)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 "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
319
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 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
321 minor mode is active.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
322
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
323 If TOGGLE has the `:menu-tag' property set to a string, that string
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
324 will be used as the label on the `modeline-minor-mode-menu' instead
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
325 of TOGGLE's symbol-name.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
326
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
327 TOGGLE may have an `:included' property, which determines whether a
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
328 menu button will be shown for this minor mode in the
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
329 `modeline-minor-mode-menu'. This should be either a boolean
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
330 variable, or an expression evaluating to t or nil. \(See the
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
331 documentation of `current-menubar' for more information.)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
332
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
333 It may have an `:active' property also, as documented in
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
334 `current-menubar'.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
336 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
337 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
338 as its value.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
339
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
340 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
341
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
342 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
343 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
344 alists.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
345
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
346 TOGGLE-FUN specifies an interactive function that is called to toggle
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
347 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
348 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
349 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
350 TOGGLE is used as the toggle function.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
351
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
352 Example: (put 'view-minor-mode :menu-tag \"View (minor)\")
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
353 (put 'view-minor-mode :included '(buffer-file-name))
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
354 (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 (let (el place
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 (add-elt #'(lambda (elt sym)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 (cond ((null after) ; add to front
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 (set sym (cons elt (symbol-value sym))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359 ((and (not (eq after t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 (setq place (memq (assq after
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 (symbol-value sym))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 (symbol-value sym))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 (setq elt (cons elt (cdr place)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 (setcdr place elt))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 (set sym (append (symbol-value sym) (list elt))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 (symbol-value sym)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 toggle-keymap)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 (if toggle-fun
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 (if (not (commandp toggle-fun))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 (error "not an interactive function: %S" toggle-fun))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 (if (commandp toggle)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (setq toggle-fun toggle)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 (if (and toggle-fun name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377 (setq toggle-keymap (make-sparse-keymap
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 (intern (concat "modeline-minor-"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 (symbol-name toggle)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 "-map"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (define-key toggle-keymap 'button2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 ;; defeat the DUMB-ASS byte-compiler, which tries to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 ;; expand the macro at compile time and fucks up.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 (eval '(make-modeline-command-wrapper toggle-fun)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (put toggle 'modeline-toggle-function toggle-fun)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 (and name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 (let ((hacked-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 (if toggle-keymap
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 (cons (let ((extent (make-extent nil nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 (set-extent-keymap extent toggle-keymap)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (set-extent-property
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 extent 'help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 (concat "button2 turns off "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 (if (symbolp toggle-fun)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 (symbol-name toggle-fun)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 (symbol-name toggle))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (cons
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 modeline-mousable-minor-mode-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (if (setq el (assq toggle minor-mode-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 (setcdr el (list hacked-name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 (funcall add-elt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 (list toggle hacked-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 'minor-mode-alist))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407 (and keymap
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 (if (setq el (assq toggle minor-mode-map-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
409 (setcdr el keymap)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
410 (funcall add-elt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
411 (cons toggle keymap)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
412 'minor-mode-map-alist)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
413 ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
414
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
415 ;; gettext anyone?
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
416 (put 'abbrev-mode :menu-tag "Abbreviation Expansion")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
417 (add-minor-mode 'abbrev-mode " Abbrev")
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
418 ;; only when visiting a file...
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
419 (add-minor-mode 'overwrite-mode 'overwrite-mode)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
420 (put 'auto-fill-function :menu-tag "Auto Fill")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
421 (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
422
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
423 ;; what's the meaning of `####' vs `FIXME' or ...?
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
424 ;; not really a minor mode... and it doesn't work right anyway.
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
425 ;;(put 'defining-kbd-macro :menu-tag "Defining kbd macro")
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
426 ;;(add-minor-mode 'defining-kbd-macro " Def") FIXME
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
427
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
428 (defun modeline-minor-mode-menu (event)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
429 "The menu that pops up when you press `button3' inside the
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
430 parentheses on the modeline."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
431 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
432 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
433 (set-buffer (event-buffer event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
434 (popup-menu-and-execute-in-window
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
435 (cons "Minor Mode Toggles"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
436 (apply 'nconc
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
437 (mapcar
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
438 #'(lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
439 (let* ((toggle-sym (car x))
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
440 (menu-tag (get toggle-sym :menu-tag nil))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
441 (toggle-fun
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
442 (or (get toggle-sym
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
443 'modeline-toggle-function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
444 (and (fboundp toggle-sym)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
445 (commandp toggle-sym)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
446 toggle-sym))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
447 (if (not toggle-fun) nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
448 (list (vector
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
449 (or (and (stringp menu-tag)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
450 menu-tag)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
451 (setq menu-tag (capitalize
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
452 (replace-in-string
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
453 (replace-in-string
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
454 (replace-in-string (if (symbolp toggle-fun)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
455 (symbol-name toggle-fun)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
456 (symbol-name toggle-sym))
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
457 "-" " ")
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
458 "minor" " (minor)")
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
459 " mode" ""))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
460 toggle-fun
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
461 :active (get toggle-sym :active t)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
462 :included (get toggle-sym :included t)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
463 :style 'toggle
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
464 :selected (and (boundp toggle-sym)
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 227
diff changeset
465 toggle-sym))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
466 minor-mode-alist)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
467 event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
468
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
469 (defvar modeline-minor-mode-map (make-sparse-keymap 'modeline-minor-mode-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
470 "Keymap consulted for mouse-clicks on the minor-mode modeline list.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
471 (define-key modeline-minor-mode-map 'button3 'modeline-minor-mode-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 (defvar modeline-minor-mode-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
474 "Extent covering the minor mode modeline strings.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
475 (set-extent-face modeline-minor-mode-extent 'modeline-mousable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
476 (set-extent-keymap modeline-minor-mode-extent modeline-minor-mode-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
477
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
478
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
479 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
480 ;;; Other ;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
481 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
482
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
483 (defun modeline-buffers-menu (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
484 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
485 (popup-menu-and-execute-in-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
486 '("Buffers Popup Menu"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
487 :filter buffers-menu-filter
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
488 ["List All Buffers" list-buffers t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
489 "--"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
490 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
491 event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
492
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
493 (defvar modeline-buffer-id-left-map
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
494 (make-sparse-keymap 'modeline-buffer-id-left-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
495 "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
496
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
497 (defvar modeline-buffer-id-right-map
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
498 (make-sparse-keymap 'modeline-buffer-id-right-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
499 "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
500
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
501 (define-key modeline-buffer-id-left-map 'button2 'mouse-unbury-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
502 (define-key modeline-buffer-id-right-map 'button2 'mouse-bury-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
503 (define-key modeline-buffer-id-left-map 'button3 'modeline-buffers-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
504 (define-key modeline-buffer-id-right-map 'button3 'modeline-buffers-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
505
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
506 (make-face 'modeline-buffer-id
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
507 "Face for the buffer ID string in the modeline.")
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
508 (set-face-parent 'modeline-buffer-id 'modeline nil '(default))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
509 (when (featurep 'x)
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
510 (set-face-foreground 'modeline-buffer-id "blue4" 'global '(default color x)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
511 (when (featurep 'x)
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
512 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default mono x))
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
513 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default grayscale x)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
514 (when (featurep 'tty)
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 259
diff changeset
515 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default tty)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
516
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
517 (defvar modeline-buffer-id-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
518 "Extent covering the whole of the buffer-id string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
519 (set-extent-face modeline-buffer-id-extent 'modeline-buffer-id)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
520
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
521 (defvar modeline-buffer-id-left-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
522 "Extent covering the left half of the buffer-id string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
523 (set-extent-keymap modeline-buffer-id-left-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
524 modeline-buffer-id-left-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
525 (set-extent-property modeline-buffer-id-left-extent 'help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
526 "button2 cycles to the previous buffer")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
527
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
528 (defvar modeline-buffer-id-right-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
529 "Extent covering the right half of the buffer-id string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
530 (set-extent-keymap modeline-buffer-id-right-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
531 modeline-buffer-id-right-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
532 (set-extent-property modeline-buffer-id-right-extent 'help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
533 "button2 cycles to the next buffer")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
534
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
535 (defconst modeline-buffer-identification
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
536 (list (cons modeline-buffer-id-left-extent (purecopy "XEmacs%N:"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
537 ; this used to be "XEmacs:"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
538 (cons modeline-buffer-id-right-extent (purecopy " %17b")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
539 "Modeline control for identifying the buffer being displayed.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
540 Its default value is \"XEmacs: %17b\" (NOT!). Major modes that edit things
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
541 other than ordinary files may change this (e.g. Info, Dired,...)")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
542 (make-variable-buffer-local 'modeline-buffer-identification)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
543
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
544 (defconst modeline-process nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
545 "Modeline control for displaying info on process status.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
546 Normally nil in most modes, since there is no process to display.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
547 (make-variable-buffer-local 'modeline-process)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
548
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
549 (defvar modeline-modified-map (make-sparse-keymap 'modeline-modified-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
550 "Keymap consulted for mouse-clicks on the modeline-modified string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
551 (define-key modeline-modified-map 'button2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
552 (make-modeline-command-wrapper 'modeline-toggle-read-only))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
553
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
554 (defvar modeline-modified-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
555 "Extent covering the modeline-modified string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
556 (set-extent-face modeline-modified-extent 'modeline-mousable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
557 (set-extent-keymap modeline-modified-extent modeline-modified-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
558 (set-extent-property modeline-modified-extent 'help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
559 "button2 toggles the buffer's read-only status")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
560
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
561 (defconst modeline-modified (purecopy '("--%1*%1+-"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
562 "Modeline control for displaying whether current buffer is modified.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
563 (make-variable-buffer-local 'modeline-modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
564
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
565 (defvar modeline-narrowed-map (make-sparse-keymap 'modeline-narrowed-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
566 "Keymap consulted for mouse-clicks on the modeline-narrowed string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
567 (define-key modeline-narrowed-map 'button2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
568 (make-modeline-command-wrapper 'widen))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
569
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
570 (defvar modeline-narrowed-extent (make-extent nil nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
571 "Extent covering the modeline-narrowed string.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
572 (set-extent-face modeline-narrowed-extent 'modeline-mousable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
573 (set-extent-keymap modeline-narrowed-extent modeline-narrowed-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
574 (set-extent-property modeline-narrowed-extent 'help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
575 "button2 widens the buffer")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
576
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
577 (setq-default
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
578 modeline-format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
579 (list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
580 (purecopy "")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
581 (cons modeline-modified-extent 'modeline-modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
582 (cons modeline-buffer-id-extent 'modeline-buffer-identification)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
583 (purecopy " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
584 'global-mode-string
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
585 (purecopy " %[(")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
586 (cons modeline-minor-mode-extent (list "" 'mode-name 'minor-mode-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
587 (cons modeline-narrowed-extent "%n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
588 'modeline-process
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
589 (purecopy ")%]----")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
590 (purecopy '(line-number-mode "L%l--"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
591 (purecopy '(column-number-mode "C%c--"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
592 (purecopy '(-3 . "%p"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
593 (purecopy "-%-")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
594
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
595 ;;; 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
596 ;;; 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
597 ;;; is.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
598
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
599 (defun modeline-toggle-read-only ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
600 "Change whether this buffer is visiting its file read-only.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
601 With arg, set read-only iff arg is positive.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
602 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
603 modeline is clicked. It will call `vc-toggle-read-only' if available,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
604 otherwise it will call the usual `toggle-read-only'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
605 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
606 (if (fboundp 'vc-toggle-read-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
607 (vc-toggle-read-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
608 (toggle-read-only)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
609
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
610 ;;; modeline.el ends here