annotate lisp/prim/modeline.el @ 208:f427b8ec4379

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