Mercurial > emacs
annotate lisp/msb.el @ 24982:c81447275ea3
(after-setting-font-hooks): New; from Eric Banchrow
<offby1@blarg.net>.
(set-frame-font): Run the hooks.
(frame-initialize): Use tty-create-frame-with-faces.
(show-trailing-whitespace): New.
(blink-cursor-mode): Function to toggle blinking cursor
mode. The cursor of selected_window blinks if the mode is enabled.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 21 Jul 1999 21:43:03 +0000 |
parents | 19424321d8e1 |
children | 1539c0070dd3 |
rev | line source |
---|---|
10228 | 1 ;;; msb.el --- Customizable buffer-selection with multiple menus. |
14169 | 2 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
3 ;; Copyright (C) 1993, 94, 95, 97, 98, 99 Free Software Foundation, Inc. |
14169 | 4 |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
5 ;; Author: Lars Lindberg <Lars.G.Lindberg@capgemini.se> |
10228 | 6 ;; Created: 8 Oct 1993 |
20901 | 7 ;; Lindberg's last update version: 3.34 |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
8 ;; Keywords: mouse buffer menu |
14169 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10228 | 13 ;; it under the terms of the GNU General Public License as published by |
14169 | 14 ;; the Free Software Foundation; either version 2, or (at your option) |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
10228 | 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
14169 | 21 |
10228 | 22 ;; You should have received a copy of the GNU General Public License |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
10228 | 26 |
27 ;;; Commentary: | |
14169 | 28 |
10228 | 29 ;; Purpose of this package: |
30 ;; 1. Offer a function for letting the user choose buffer, | |
31 ;; not necessarily for switching to it. | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
32 ;; 2. Make a better mouse-buffer-menu. This is done as a global |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
33 ;; minor mode, msb-mode. |
10228 | 34 ;; |
35 ;; Customization: | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
36 ;; Look at the variable `msb-menu-cond' for deciding what menus you |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
37 ;; want. It's not that hard to customize, despite my not-so-good |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
38 ;; doc-string. Feel free to send me a better doc-string. |
10228 | 39 ;; There are some constants for you to try here: |
40 ;; msb--few-menus | |
41 ;; msb--very-many-menus (default) | |
20901 | 42 ;; |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
43 ;; Look at the variable `msb-item-handling-function' for customization |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
44 ;; of the appearance of every menu item. Try for instance setting |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
45 ;; it to `msb-alon-item-handler'. |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
46 ;; |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
47 ;; Look at the variable `msb-item-sort-function' for customization |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
48 ;; of sorting the menus. Set it to t for instance, which means no |
10228 | 49 ;; sorting - you will get latest used buffer first. |
50 ;; | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
51 ;; Also check out the variable `msb-display-invisible-buffers-p'. |
10228 | 52 |
53 ;; Known bugs: | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
54 ;; - Files-by-directory |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
55 ;; + No possibility to show client/changed buffers separately. |
20901 | 56 ;; + All file buffers only appear in a file sub-menu, they will |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
57 ;; for instance not appear in the Mail sub-menu. |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
58 |
10228 | 59 ;; Future enhancements: |
60 | |
61 ;;; Thanks goes to | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
62 ;; Mark Brader <msb@sq.com> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
63 ;; Jim Berry <m1jhb00@FRB.GOV> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
64 ;; Hans Chalupsky <hans@cs.Buffalo.EDU> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
65 ;; Larry Rosenberg <ljr@ictv.com> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
66 ;; Will Henney <will@astroscu.unam.mx> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
67 ;; Jari Aalto <jaalto@tre.tele.nokia.fi> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
68 ;; Michael Kifer <kifer@sbkifer.cs.sunysb.edu> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
69 ;; Gael Marziou <gael@gnlab030.grenoble.hp.com> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
70 ;; Dave Gillespie <daveg@thymus.synaptics.com> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
71 ;; Alon Albert <alon@milcse.rtsg.mot.com> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
72 ;; Kevin Broadey, <KevinB@bartley.demon.co.uk> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
73 ;; Ake Stenhof <ake@cadpoint.se> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
74 ;; Richard Stallman <rms@gnu.ai.mit.edu> |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
75 ;; Steve Fisk <fisk@medved.bowdoin.edu> |
10228 | 76 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
77 ;; This version turned into a global minor mode by Dave Love. |
10228 | 78 ;;; Code: |
79 | |
80 (require 'cl) | |
81 | |
82 ;;; | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
83 ;;; Some example constants to be used for `msb-menu-cond'. See that |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
84 ;;; variable for more information. Please note that if the condition |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
85 ;;; returns `multi', then the buffer can appear in several menus. |
10228 | 86 ;;; |
87 (defconst msb--few-menus | |
88 '(((and (boundp 'server-buffer-clients) | |
89 server-buffer-clients | |
90 'multi) | |
91 3030 | |
92 "Clients (%d)") | |
93 ((and msb-display-invisible-buffers-p | |
94 (msb-invisible-buffer-p) | |
95 'multi) | |
96 3090 | |
97 "Invisible buffers (%d)") | |
98 ((eq major-mode 'dired-mode) | |
99 2010 | |
100 "Dired (%d)" | |
101 msb-dired-item-handler | |
102 msb-sort-by-directory) | |
103 ((eq major-mode 'Man-mode) | |
104 4090 | |
105 "Manuals (%d)") | |
106 ((eq major-mode 'w3-mode) | |
107 4020 | |
108 "WWW (%d)") | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
109 ((or (memq major-mode '(rmail-mode rmail-edit-mode vm-summary-mode vm-mode mail-mode)) |
10228 | 110 (memq major-mode '(mh-letter-mode |
111 mh-show-mode | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
112 mh-folder-mode)) |
10228 | 113 (memq major-mode '(gnus-summary-mode |
114 news-reply-mode | |
115 gnus-group-mode | |
116 gnus-article-mode | |
117 gnus-kill-file-mode | |
118 gnus-browse-killed-mode))) | |
119 4010 | |
120 "Mail (%d)") | |
121 ((not buffer-file-name) | |
122 4099 | |
123 "Buffers (%d)") | |
124 ('no-multi | |
125 1099 | |
126 "Files (%d)"))) | |
127 | |
128 (defconst msb--very-many-menus | |
129 '(((and (boundp 'server-buffer-clients) | |
130 server-buffer-clients | |
131 'multi) | |
132 1010 | |
133 "Clients (%d)") | |
134 ((and (boundp 'vc-mode) vc-mode 'multi) | |
135 1020 | |
136 "Version Control (%d)") | |
137 ((and buffer-file-name | |
138 (buffer-modified-p) | |
139 'multi) | |
140 1030 | |
141 "Changed files (%d)") | |
142 ((and (get-buffer-process (current-buffer)) | |
143 'multi) | |
144 1040 | |
145 "Processes (%d)") | |
146 ((and msb-display-invisible-buffers-p | |
147 (msb-invisible-buffer-p) | |
148 'multi) | |
149 1090 | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
150 "Invisible buffers (%d)") |
10228 | 151 ((eq major-mode 'dired-mode) |
152 2010 | |
153 "Dired (%d)" | |
154 ;; Note this different menu-handler | |
155 msb-dired-item-handler | |
156 ;; Also note this item-sorter | |
157 msb-sort-by-directory) | |
158 ((eq major-mode 'Man-mode) | |
20901 | 159 5030 |
10228 | 160 "Manuals (%d)") |
161 ((eq major-mode 'w3-mode) | |
20901 | 162 5020 |
10228 | 163 "WWW (%d)") |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
164 ((or (memq major-mode '(rmail-mode rmail-edit-mode vm-summary-mode vm-mode mail-mode)) |
10228 | 165 (memq major-mode '(mh-letter-mode |
166 mh-show-mode | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
167 mh-folder-mode)) |
10228 | 168 (memq major-mode '(gnus-summary-mode |
169 news-reply-mode | |
170 gnus-group-mode | |
171 gnus-article-mode | |
172 gnus-kill-file-mode | |
173 gnus-browse-killed-mode))) | |
20901 | 174 5010 |
10228 | 175 "Mail (%d)") |
176 ;; Catchup for all non-file buffers | |
177 ((and (not buffer-file-name) | |
178 'no-multi) | |
20901 | 179 5099 |
10228 | 180 "Other non-file buffers (%d)") |
181 ((and (string-match "/\\.[^/]*$" buffer-file-name) | |
182 'multi) | |
183 3090 | |
184 "Hidden Files (%d)") | |
185 ((memq major-mode '(c-mode c++-mode)) | |
186 3010 | |
187 "C/C++ Files (%d)") | |
188 ((eq major-mode 'emacs-lisp-mode) | |
189 3020 | |
190 "Elisp Files (%d)") | |
191 ((eq major-mode 'latex-mode) | |
192 3030 | |
193 "LaTex Files (%d)") | |
194 ('no-multi | |
195 3099 | |
196 "Other files (%d)"))) | |
197 | |
198 ;; msb--many-menus is obsolete | |
199 (defvar msb--many-menus msb--very-many-menus) | |
200 | |
201 ;;; | |
202 ;;; Customizable variables | |
203 ;;; | |
204 | |
20901 | 205 (defgroup msb nil |
206 "Customizable buffer-selection with multiple menus." | |
207 :prefix "msb-" | |
208 :group 'mouse) | |
10228 | 209 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
210 ;;;###autoload |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
211 (defcustom msb-mode nil |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
212 "Toggle msb-mode. |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
213 Setting this variable directly does not take effect; |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
214 use either \\[customize] or the function `msb-mode'." |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
215 :set (lambda (symbol value) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
216 (msb-mode (or value 0))) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
217 :initialize 'custom-initialize-default |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
218 :version "20.4" |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
219 :type 'boolean |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
220 :group 'msb |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
221 :require 'msb) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
222 |
20901 | 223 (defun msb-custom-set (symbol value) |
224 "Set the value of custom variables for msb." | |
225 (set symbol value) | |
226 (if (featurep 'msb) | |
227 ;; wait until package has been loaded before bothering to update | |
228 ;; the buffer lists. | |
229 (menu-bar-update-buffers t)) | |
230 ) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
231 |
20901 | 232 (defcustom msb-menu-cond msb--very-many-menus |
13998
2f2d3995b57f
(msb-max-file-menu-items, msb-menu-cond): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13372
diff
changeset
|
233 "*List of criteria for splitting the mouse buffer menu. |
10228 | 234 The elements in the list should be of this type: |
235 (CONDITION MENU-SORT-KEY MENU-TITLE ITEM-HANDLING-FN ITEM-SORT-FN). | |
236 | |
237 When making the split, the buffers are tested one by one against the | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
238 CONDITION, just like a Lisp cond: When hitting a true condition, the |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
239 other criteria are *not* tested and the buffer name will appear in the |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
240 menu with the menu-title corresponding to the true condition. |
10228 | 241 |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
242 If the condition returns the symbol `multi', then the buffer will be |
10228 | 243 added to this menu *and* tested for other menus too. If it returns |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
244 `no-multi', then the buffer will only be added if it hasn't been added |
10228 | 245 to any other menu. |
246 | |
247 During this test, the buffer in question is the current buffer, and | |
248 the test is surrounded by calls to `save-excursion' and | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
249 `save-match-data'. |
10228 | 250 |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
251 The categories are sorted by MENU-SORT-KEY. Smaller keys are on top. |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
252 nil means don't display this menu. |
10228 | 253 |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
254 MENU-TITLE is really a format. If you add %d in it, the %d is |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
255 replaced with the number of items in that menu. |
10228 | 256 |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
257 ITEM-HANDLING-FN, is optional. If it is supplied and is a function, |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
258 than it is used for displaying the items in that particular buffer |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
259 menu, otherwise the function pointed out by |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
260 `msb-item-handling-function' is used. |
10228 | 261 |
262 ITEM-SORT-FN, is also optional. | |
263 If it is not supplied, the function pointed out by | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
264 `msb-item-sort-function' is used. |
10228 | 265 If it is nil, then no sort takes place and the buffers are presented |
266 in least-recently-used order. | |
267 If it is t, then no sort takes place and the buffers are presented in | |
268 most-recently-used order. | |
269 If it is supplied and non-nil and not t than it is used for sorting | |
270 the items in that particular buffer menu. | |
271 | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
272 Note1: There should always be a `catch-all' as last element, in this |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
273 list. That is an element like (t TITLE ITEM-HANDLING-FUNCTION). |
10228 | 274 Note2: A buffer menu appears only if it has at least one buffer in it. |
275 Note3: If you have a CONDITION that can't be evaluated you will get an | |
20901 | 276 error every time you do \\[msb]." |
277 :type `(choice (const :tag "long" :value ,msb--very-many-menus) | |
278 (const :tag "short" :value ,msb--few-menus)) | |
279 :set 'msb-custom-set | |
280 :group 'msb) | |
281 | |
282 (defcustom msb-modes-key 4000 | |
283 "The sort key for files sorted by mode." | |
284 :type 'integer | |
285 :set 'msb-custom-set | |
21670
808ecc2eaa84
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20901
diff
changeset
|
286 :group 'msb |
808ecc2eaa84
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20901
diff
changeset
|
287 :version "20.3") |
20901 | 288 |
289 (defcustom msb-separator-diff 100 | |
290 "*Non-nil means use separators. | |
291 The separators will appear between all menus that have a sorting key | |
292 that differs by this value or more." | |
293 :type '(choice integer (const nil)) | |
294 :set 'msb-custom-set | |
295 :group 'msb) | |
296 | |
297 (defvar msb-files-by-directory-sort-key 0 | |
298 "*The sort key for files sorted by directory.") | |
299 | |
300 (defcustom msb-max-menu-items 15 | |
301 "*The maximum number of items in a menu. | |
302 If this variable is set to 15 for instance, then the submenu will be | |
303 split up in minor parts, 15 items each. Nil means no limit." | |
304 :type '(choice integer (const nil)) | |
305 :set 'msb-custom-set | |
306 :group 'msb) | |
307 | |
308 (defcustom msb-max-file-menu-items 10 | |
309 "*The maximum number of items from different directories. | |
310 | |
311 When the menu is of type `file by directory', this is the maximum | |
312 number of buffers that are clumped together from different | |
313 directories. | |
314 | |
315 Set this to 1 if you want one menu per directory instead of clumping | |
316 them together. | |
317 | |
318 If the value is not a number, then the value 10 is used." | |
319 :type 'integer | |
320 :set 'msb-custom-set | |
321 :group 'msb) | |
322 | |
323 (defcustom msb-most-recently-used-sort-key -1010 | |
324 "*Where should the menu with the most recently used buffers be placed?" | |
325 :type 'integer | |
326 :set 'msb-custom-set | |
327 :group 'msb) | |
328 | |
329 (defcustom msb-display-most-recently-used 15 | |
330 "*How many buffers should be in the most-recently-used menu. | |
331 No buffers at all if less than 1 or nil (or any non-number)." | |
332 :type 'integer | |
333 :set 'msb-custom-set | |
334 :group 'msb) | |
10228 | 335 |
20901 | 336 (defcustom msb-most-recently-used-title "Most recently used (%d)" |
337 "*The title for the most-recently-used menu." | |
338 :type 'string | |
339 :set 'msb-custom-set | |
340 :group 'msb) | |
341 | |
342 (defvar msb-horizontal-shift-function '(lambda () 0) | |
343 "*Function that specifies how many pixels to shift the top menu leftwards.") | |
344 | |
345 (defcustom msb-display-invisible-buffers-p nil | |
346 "*Show invisible buffers or not. | |
347 Non-nil means that the buffer menu should include buffers that have | |
348 names that starts with a space character." | |
349 :type 'boolean | |
350 :set 'msb-custom-set | |
351 :group 'msb) | |
352 | |
353 (defvar msb-item-handling-function 'msb-item-handler | |
354 "*The appearance of a buffer menu. | |
355 | |
356 The default function to call for handling the appearance of a menu | |
357 item. It should take to arguments, BUFFER and MAX-BUFFER-NAME-LENGTH, | |
358 where the latter is the max length of all buffer names. | |
359 | |
360 The function should return the string to use in the menu. | |
361 | |
362 When the function is called, BUFFER is the current buffer. This | |
363 function is called for items in the variable `msb-menu-cond' that have | |
364 nil as ITEM-HANDLING-FUNCTION. See `msb-menu-cond' for more | |
365 information.") | |
366 | |
367 (defcustom msb-item-sort-function 'msb-sort-by-name | |
368 "*The order of items in a buffer menu. | |
369 | |
370 The default function to call for handling the order of items in a menu | |
371 item. This function is called like a sort function. The items look | |
372 like (ITEM-NAME . BUFFER). | |
373 | |
374 ITEM-NAME is the name of the item that will appear in the menu. | |
375 BUFFER is the buffer, this is not necessarily the current buffer. | |
376 | |
377 Set this to nil or t if you don't want any sorting (faster)." | |
378 :type '(choice (const msb-sort-by-name) | |
379 (const :tag "Newest first" t) | |
380 (const :tag "Oldest first" nil)) | |
381 :set 'msb-custom-set | |
382 :group 'msb | |
383 ) | |
384 | |
385 (defcustom msb-files-by-directory nil | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
386 "*Non-nil means that files should be sorted by directory. |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
387 This is instead of the groups in `msb-menu-cond'." |
20901 | 388 :type 'boolean |
389 :set 'msb-custom-set | |
390 :group 'msb) | |
391 | |
392 (defcustom msb-after-load-hooks nil | |
393 "Hooks to be run after the msb package has been loaded." | |
394 :type 'hook | |
395 :set 'msb-custom-set | |
396 :group 'msb) | |
10228 | 397 |
398 ;;; | |
399 ;;; Internal variables | |
400 ;;; | |
401 | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
402 ;; Home directory for the current user |
20901 | 403 (defconst msb--home-dir |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
404 (condition-case nil |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
405 (substitute-in-file-name "$HOME") |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
406 ;; If $HOME isn't defined, use nil |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
407 (error nil))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
408 |
10228 | 409 ;; The last calculated menu. |
410 (defvar msb--last-buffer-menu nil) | |
411 | |
412 ;; If this is non-nil, then it is a string that describes the error. | |
413 (defvar msb--error nil) | |
414 | |
415 ;;; | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
416 ;;; Some example function to be used for `msb-item-handling-function'. |
10228 | 417 ;;; |
418 (defun msb-item-handler (buffer &optional maxbuf) | |
419 "Create one string item, concerning BUFFER, for the buffer menu. | |
420 The item looks like: | |
421 *% <buffer-name> | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
422 The `*' appears only if the buffer is marked as modified. |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
423 The `%' appears only if the buffer is read-only. |
10228 | 424 Optional second argument MAXBUF is completely ignored." |
425 (let ((name (buffer-name)) | |
426 (modified (if (buffer-modified-p) "*" " ")) | |
427 (read-only (if buffer-read-only "%" " "))) | |
428 (format "%s%s %s" modified read-only name))) | |
429 | |
430 | |
431 (eval-when-compile (require 'dired)) | |
432 | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
433 ;; `dired' can be called with a list of the form (directory file1 file2 ...) |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
434 ;; which causes `dired-directory' to be in the same form. |
10228 | 435 (defun msb--dired-directory () |
436 (cond ((stringp dired-directory) | |
437 (abbreviate-file-name (expand-file-name dired-directory))) | |
438 ((consp dired-directory) | |
439 (abbreviate-file-name (expand-file-name (car dired-directory)))) | |
440 (t | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
441 (error "Unknown type of `dired-directory' in buffer %s" |
10228 | 442 (buffer-name))))) |
443 | |
444 (defun msb-dired-item-handler (buffer &optional maxbuf) | |
445 "Create one string item, concerning a dired BUFFER, for the buffer menu. | |
446 The item looks like: | |
447 *% <buffer-name> | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
448 The `*' appears only if the buffer is marked as modified. |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
449 The `%' appears only if the buffer is read-only. |
10228 | 450 Optional second argument MAXBUF is completely ignored." |
451 (let ((name (msb--dired-directory)) | |
452 (modified (if (buffer-modified-p) "*" " ")) | |
453 (read-only (if buffer-read-only "%" " "))) | |
454 (format "%s%s %s" modified read-only name))) | |
455 | |
456 (defun msb-alon-item-handler (buffer maxbuf) | |
457 "Create one string item for the buffer menu. | |
458 The item looks like: | |
459 <buffer-name> *%# <file-name> | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
460 The `*' appears only if the buffer is marked as modified. |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
461 The `%' appears only if the buffer is read-only. |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
462 The `#' appears only version control file (SCCS/RCS)." |
10228 | 463 (format (format "%%%ds %%s%%s%%s %%s" maxbuf) |
464 (buffer-name buffer) | |
465 (if (buffer-modified-p) "*" " ") | |
466 (if buffer-read-only "%" " ") | |
467 (if (and (boundp 'vc-mode) vc-mode) "#" " ") | |
468 (or buffer-file-name ""))) | |
469 | |
470 ;;; | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
471 ;;; Some example function to be used for `msb-item-sort-function'. |
10228 | 472 ;;; |
473 (defun msb-sort-by-name (item1 item2) | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
474 "Sort the items ITEM1 and ITEM2 by their `buffer-name'. |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
475 An item looks like (NAME . BUFFER)." |
10228 | 476 (string-lessp (buffer-name (cdr item1)) |
477 (buffer-name (cdr item2)))) | |
478 | |
479 | |
480 (defun msb-sort-by-directory (item1 item2) | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
481 "Sort the items ITEM1 and ITEM2 by directory name. Made for dired. |
10228 | 482 An item look like (NAME . BUFFER)." |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
483 (string-lessp (save-excursion (set-buffer (cdr item1)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
484 (msb--dired-directory)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
485 (save-excursion (set-buffer (cdr item2)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
486 (msb--dired-directory)))) |
10228 | 487 |
488 ;;; | |
489 ;;; msb | |
490 ;;; | |
491 ;;; This function can be used instead of (mouse-buffer-menu EVENT) | |
492 ;;; function in "mouse.el". | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
493 ;;; |
10228 | 494 (defun msb (event) |
495 "Pop up several menus of buffers for selection with the mouse. | |
496 This command switches buffers in the window that you clicked on, and | |
497 selects that window. | |
498 | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
499 See the function `mouse-select-buffer' and the variable |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
500 `msb-menu-cond' for more information about how the menus are split." |
10228 | 501 (interactive "e") |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
502 (let ((old-window (selected-window)) |
10228 | 503 (window (posn-window (event-start event)))) |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
504 (unless (framep window) (select-window window)) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
505 (let ((buffer (mouse-select-buffer event))) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
506 (if buffer |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
507 (switch-to-buffer buffer) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
508 (select-window old-window)))) |
10228 | 509 nil) |
510 | |
511 ;;; | |
512 ;;; Some supportive functions | |
513 ;;; | |
514 (defun msb-invisible-buffer-p (&optional buffer) | |
515 "Return t if optional BUFFER is an \"invisible\" buffer. | |
516 If the argument is left out or nil, then the current buffer is considered." | |
517 (and (> (length (buffer-name buffer)) 0) | |
518 (eq ?\ (aref (buffer-name buffer) 0)))) | |
519 | |
20505 | 520 ;; Strip one hierarchy level from the end of DIR. |
521 (defun msb--strip-dir (dir) | |
20758
f5a113b108ff
(msb--strip-dir): Use Emacs filename primitives, not regexps.
Richard M. Stallman <rms@gnu.org>
parents:
20506
diff
changeset
|
522 (file-name-directory (directory-file-name dir))) |
10228 | 523 |
524 ;; Create an alist with all buffers from LIST that lies under the same | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
525 ;; directory will be in the same item as the directory string. |
20506
c096aa581013
Fix mailer-introduced garbling.
Richard M. Stallman <rms@gnu.org>
parents:
20505
diff
changeset
|
526 ;; ((PATH1 . (BUFFER-1 BUFFER-2 ...)) (PATH2 . (BUFFER-K BUFFER-K+1...)) ...) |
10228 | 527 (defun msb--init-file-alist (list) |
528 (let ((buffer-alist | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
529 ;; Make alist that looks like |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
530 ;; ((PATH-1 BUFFER-1) (PATH-2 BUFFER-2) ...) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
531 ;; sorted on PATH-x |
10228 | 532 (sort (mapcan |
20901 | 533 (lambda (buffer) |
534 (let ((file-name (expand-file-name (buffer-file-name buffer)))) | |
535 (when file-name | |
536 (list (cons (msb--strip-dir file-name) buffer))))) | |
10228 | 537 list) |
20901 | 538 (lambda (item1 item2) |
539 (string< (car item1) (car item2)))))) | |
20884
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
540 ;; Now clump buffers together that have the same path |
10228 | 541 ;; Make alist that looks like |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
542 ;; ((PATH1 . (BUFFER-1 BUFFER-2 ...)) (PATH2 . (BUFFER-K)) ...) |
10228 | 543 (let ((path nil) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
544 (buffers nil)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
545 (nconc |
20901 | 546 (mapcan (lambda (item) |
547 (cond | |
548 ((and path | |
549 (string= path (car item))) | |
550 ;; The same path as earlier: Add to current list of | |
551 ;; buffers. | |
552 (push (cdr item) buffers) | |
553 ;; This item should not be added to list | |
554 nil) | |
555 (t | |
556 ;; New path | |
557 (let ((result (and path (cons path buffers)))) | |
558 (setq path (car item)) | |
559 (setq buffers (list (cdr item))) | |
560 ;; Add the last result the list. | |
561 (and result (list result)))))) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
562 buffer-alist) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
563 ;; Add the last result to the list |
10228 | 564 (list (cons path buffers)))))) |
565 | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
566 ;; Format a suitable title for the menu item. |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
567 (defun msb--format-title (top-found-p path number-of-items) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
568 (let ((new-path path)) |
20505 | 569 (when (and msb--home-dir |
570 (string-match (concat "^" msb--home-dir) path)) | |
20901 | 571 (setq new-path (concat "~" |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
572 (substring path (match-end 0))))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
573 (format (if top-found-p "%s... (%d)" "%s (%d)") |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
574 new-path number-of-items))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
575 |
20884
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
576 ;; Variables for debugging. |
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
577 (defvar msb--choose-file-menu-list) |
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
578 (defvar msb--choose-file-menu-arg-list) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
579 |
10228 | 580 ;; Choose file-menu with respect to directory for every buffer in LIST. |
581 (defun msb--choose-file-menu (list) | |
20884
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
582 (setq msb--choose-file-menu-arg-list list) |
10228 | 583 (let ((buffer-alist (msb--init-file-alist list)) |
584 (final-list nil) | |
585 (max-clumped-together (if (numberp msb-max-file-menu-items) | |
586 msb-max-file-menu-items | |
587 10)) | |
588 (top-found-p nil) | |
589 (last-path nil) | |
20901 | 590 first rest path buffers old-path) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
591 ;; Prepare for looping over all items in buffer-alist |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
592 (setq first (car buffer-alist) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
593 rest (cdr buffer-alist) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
594 path (car first) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
595 buffers (cdr first)) |
20884
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
596 (setq msb--choose-file-menu-list (copy-list rest)) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
597 ;; This big loop tries to clump buffers together that have a |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
598 ;; similar name. Remember that buffer-alist is sorted based on the |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
599 ;; path for the buffers. |
10228 | 600 (while rest |
601 (let ((found-p nil) | |
602 (tmp-rest rest) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
603 result |
10228 | 604 new-path item) |
605 (setq item (car tmp-rest)) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
606 ;; Clump together the "rest"-buffers that have a path that is |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
607 ;; a subpath of the current one. |
10228 | 608 (while (and tmp-rest |
609 (<= (length buffers) max-clumped-together) | |
610 (>= (length (car item)) (length path)) | |
611 (string= path (substring (car item) 0 (length path)))) | |
612 (setq found-p t) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
613 (setq buffers (append buffers (cdr item))) ;nconc is faster than append |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
614 (setq tmp-rest (cdr tmp-rest) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
615 item (car tmp-rest))) |
10228 | 616 (cond |
617 ((> (length buffers) max-clumped-together) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
618 ;; Oh, we failed. Too many buffers clumped together. |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
619 ;; Just use the original ones for the result. |
10228 | 620 (setq last-path (car first)) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
621 (push (cons (msb--format-title top-found-p |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
622 (car first) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
623 (length (cdr first))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
624 (cdr first)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
625 final-list) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
626 (setq top-found-p nil) |
10228 | 627 (setq first (car rest) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
628 rest (cdr rest) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
629 path (car first) |
10228 | 630 buffers (cdr first))) |
631 (t | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
632 ;; The first pass of clumping together worked out, go ahead |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
633 ;; with this result. |
10228 | 634 (when found-p |
635 (setq top-found-p t) | |
636 (setq first (cons path buffers) | |
637 rest tmp-rest)) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
638 ;; Now see if we can clump more buffers together if we go up |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
639 ;; one step in the file hierarchy. |
20901 | 640 ;; If path isn't changed by msb--strip-dir, we are looking |
641 ;; at the machine name component of an ange-ftp filename. | |
642 (setq old-path path) | |
20505 | 643 (setq path (msb--strip-dir path) |
10228 | 644 buffers (cdr first)) |
20901 | 645 (if (equal old-path path) |
646 (setq last-path path)) | |
10228 | 647 (when (and last-path |
648 (or (and (>= (length path) (length last-path)) | |
649 (string= last-path | |
650 (substring path 0 (length last-path)))) | |
651 (and (< (length path) (length last-path)) | |
652 (string= path | |
653 (substring last-path 0 (length path)))))) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
654 ;; We have reached the same place in the file hierarchy as |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
655 ;; the last result, so we should quit at this point and |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
656 ;; take what we have as result. |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
657 (push (cons (msb--format-title top-found-p |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
658 (car first) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
659 (length (cdr first))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
660 (cdr first)) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
661 final-list) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
662 (setq top-found-p nil) |
10228 | 663 (setq first (car rest) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
664 rest (cdr rest) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
665 path (car first) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
666 buffers (cdr first))))))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
667 ;; Now take care of the last item. |
20901 | 668 (when first |
669 (push (cons (msb--format-title top-found-p | |
670 (car first) | |
671 (length (cdr first))) | |
672 (cdr first)) | |
673 final-list)) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
674 (setq top-found-p nil) |
10228 | 675 (nreverse final-list))) |
676 | |
677 ;; Create a vector as: | |
678 ;; [BUFFER-LIST-VARIABLE CONDITION MENU-SORT-KEY MENU-TITLE ITEM-HANDLER SORTER) | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
679 ;; from an element in `msb-menu-cond'. See that variable for a |
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
680 ;; description of its elements. |
10228 | 681 (defun msb--create-function-info (menu-cond-elt) |
682 (let* ((list-symbol (make-symbol "-msb-buffer-list")) | |
683 (tmp-ih (and (> (length menu-cond-elt) 3) | |
684 (nth 3 menu-cond-elt))) | |
685 (item-handler (if (and tmp-ih (fboundp tmp-ih)) | |
686 tmp-ih | |
687 msb-item-handling-function)) | |
688 (tmp-s (if (> (length menu-cond-elt) 4) | |
689 (nth 4 menu-cond-elt) | |
690 msb-item-sort-function)) | |
691 (sorter (if (or (fboundp tmp-s) | |
692 (null tmp-s) | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
693 (eq tmp-s t)) |
10228 | 694 tmp-s |
695 msb-item-sort-function))) | |
696 (when (< (length menu-cond-elt) 3) | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
697 (error "Wrong format of msb-menu-cond")) |
10228 | 698 (when (and (> (length menu-cond-elt) 3) |
699 (not (fboundp tmp-ih))) | |
700 (signal 'invalid-function (list tmp-ih))) | |
701 (when (and (> (length menu-cond-elt) 4) | |
702 tmp-s | |
703 (not (fboundp tmp-s)) | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
704 (not (eq tmp-s t))) |
10228 | 705 (signal 'invalid-function (list tmp-s))) |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
706 (set list-symbol ()) |
10228 | 707 (vector list-symbol ;BUFFER-LIST-VARIABLE |
708 (nth 0 menu-cond-elt) ;CONDITION | |
709 (nth 1 menu-cond-elt) ;SORT-KEY | |
710 (nth 2 menu-cond-elt) ;MENU-TITLE | |
711 item-handler ;ITEM-HANDLER | |
712 sorter) ;SORTER | |
713 )) | |
714 | |
715 ;; This defsubst is only used in `msb--choose-menu' below. It was | |
20901 | 716 ;; pulled out merely to make the code somewhat clearer. The indentation |
10228 | 717 ;; level was too big. |
718 (defsubst msb--collect (function-info-vector) | |
719 (let ((result nil) | |
720 (multi-flag nil) | |
721 function-info-list) | |
722 (setq function-info-list | |
723 (loop for fi | |
724 across function-info-vector | |
725 if (and (setq result | |
726 (eval (aref fi 1))) ;Test CONDITION | |
727 (not (and (eq result 'no-multi) | |
728 multi-flag)) | |
729 (progn (when (eq result 'multi) | |
730 (setq multi-flag t)) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
731 t)) |
10228 | 732 collect fi |
733 until (and result | |
734 (not (eq result 'multi))))) | |
735 (when (and (not function-info-list) | |
736 (not result)) | |
737 (error "No catch-all in msb-menu-cond!")) | |
738 function-info-list)) | |
739 | |
740 ;; Adds BUFFER to the menu depicted by FUNCTION-INFO | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
741 ;; All side-effects. Adds an element of form (BUFFER-TITLE . BUFFER) |
10228 | 742 ;; to the buffer-list variable in function-info. |
743 (defun msb--add-to-menu (buffer function-info max-buffer-name-length) | |
744 (let ((list-symbol (aref function-info 0))) ;BUFFER-LIST-VARIABLE | |
745 ;; Here comes the hairy side-effect! | |
746 (set list-symbol | |
747 (cons (cons (funcall (aref function-info 4) ;ITEM-HANDLER | |
748 buffer | |
749 max-buffer-name-length) | |
750 buffer) | |
751 (eval list-symbol))))) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
752 |
10228 | 753 ;; Selects the appropriate menu for BUFFER. |
754 ;; This is all side-effects, folks! | |
755 ;; This should be optimized. | |
756 (defsubst msb--choose-menu (buffer function-info-vector max-buffer-name-length) | |
757 (unless (and (not msb-display-invisible-buffers-p) | |
758 (msb-invisible-buffer-p buffer)) | |
759 (condition-case nil | |
760 (save-excursion | |
761 (set-buffer buffer) | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
762 ;; Menu found. Add to this menu |
20901 | 763 (mapc (lambda (function-info) |
764 (msb--add-to-menu buffer function-info max-buffer-name-length)) | |
10228 | 765 (msb--collect function-info-vector))) |
766 (error (unless msb--error | |
767 (setq msb--error | |
768 (format | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
769 "In msb-menu-cond, error for buffer `%s'." |
10228 | 770 (buffer-name buffer))) |
14427
ac3101efc47e
(msb--choose-menu): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14292
diff
changeset
|
771 (error "%s" msb--error)))))) |
10228 | 772 |
773 ;; Return (SORT-KEY TITLE . BUFFER-LIST) or nil if the | |
774 ;; buffer-list is empty. | |
775 (defun msb--create-sort-item (function-info) | |
776 (let ((buffer-list (eval (aref function-info 0)))) | |
777 (when buffer-list | |
778 (let ((sorter (aref function-info 5)) ;SORTER | |
779 (sort-key (aref function-info 2))) ;MENU-SORT-KEY | |
780 (when sort-key | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
781 (cons sort-key |
10228 | 782 (cons (format (aref function-info 3) ;MENU-TITLE |
783 (length buffer-list)) | |
784 (cond | |
785 ((null sorter) | |
786 buffer-list) | |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
787 ((eq sorter t) |
10228 | 788 (nreverse buffer-list)) |
789 (t | |
790 (sort buffer-list sorter)))))))))) | |
791 | |
20901 | 792 ;; Return ALIST as a sorted, aggregated alist, where all items with |
793 ;; the same car element (according to SAME-PREDICATE) are aggregated | |
794 ;; together. The alist is first sorted by SORT-PREDICATE. | |
795 ;; Example: | |
796 ;; (msb--aggregate-alist | |
797 ;; '((a . a1) (a . a2) (b . b1) (c . c3) (a . a4) (a . a3) (b . b3) (b . b2)) | |
798 ;; (function string=) | |
799 ;; (lambda (item1 item2) | |
800 ;; (string< (symbol-name item1) (symbol-name item2)))) | |
801 ;; results in | |
802 ;; ((a a1 a2 a4 a3) (b b1 b3 b2) (c c3)) | |
803 (defun msb--aggregate-alist (alist same-predicate sort-predicate) | |
804 (when (not (null alist)) | |
805 (let (result | |
806 same | |
807 tmp-old-car | |
808 tmp-same | |
809 (first-time-p t) | |
810 old-car) | |
811 (nconc | |
812 (mapcan (lambda (item) | |
813 (cond | |
814 (first-time-p | |
815 (push (cdr item) same) | |
816 (setq first-time-p nil) | |
817 (setq old-car (car item)) | |
818 nil) | |
819 ((funcall same-predicate (car item) old-car) | |
820 (push (cdr item) same) | |
821 nil) | |
822 (t | |
823 (setq tmp-same same | |
824 tmp-old-car old-car) | |
825 (setq same (list (cdr item)) | |
826 old-car (car item)) | |
827 (list (cons tmp-old-car (nreverse tmp-same)))))) | |
828 (sort alist (lambda (item1 item2) | |
829 (funcall sort-predicate (car item1) (car item2))))) | |
830 (list (cons old-car (nreverse same))))))) | |
831 | |
832 | |
833 (defun msb--mode-menu-cond () | |
834 (let ((key msb-modes-key)) | |
835 (mapcar (lambda (item) | |
836 (incf key) | |
837 (list `( eq major-mode (quote ,(car item))) | |
838 key | |
839 (concat (cdr item) " (%d)"))) | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
840 (sort |
20901 | 841 (let ((mode-list nil)) |
842 (mapc (lambda (buffer) | |
843 (save-excursion | |
844 (set-buffer buffer) | |
845 (when (and (not (msb-invisible-buffer-p)) | |
846 (not (assq major-mode mode-list)) | |
847 (push (cons major-mode mode-name) | |
848 mode-list))))) | |
849 (cdr (buffer-list))) | |
850 mode-list) | |
851 (lambda (item1 item2) | |
852 (string< (cdr item1) (cdr item2))))))) | |
853 | |
10228 | 854 ;; Returns a list on the form ((TITLE . BUFFER-LIST)) for |
855 ;; the most recently used buffers. | |
856 (defun msb--most-recently-used-menu (max-buffer-name-length) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
857 (when (and (numberp msb-display-most-recently-used) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
858 (> msb-display-most-recently-used 0)) |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
859 (let* ((buffers (cdr (buffer-list))) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
860 (most-recently-used |
10228 | 861 (loop with n = 0 |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
862 for buffer in buffers |
10228 | 863 if (save-excursion |
864 (set-buffer buffer) | |
865 (and (not (msb-invisible-buffer-p)) | |
866 (not (eq major-mode 'dired-mode)))) | |
867 collect (save-excursion | |
868 (set-buffer buffer) | |
869 (cons (funcall msb-item-handling-function | |
870 buffer | |
871 max-buffer-name-length) | |
872 buffer)) | |
873 and do (incf n) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
874 until (>= n msb-display-most-recently-used)))) |
10228 | 875 (cons (if (stringp msb-most-recently-used-title) |
876 (format msb-most-recently-used-title | |
877 (length most-recently-used)) | |
878 (signal 'wrong-type-argument (list msb-most-recently-used-title))) | |
879 most-recently-used)))) | |
880 | |
881 (defun msb--create-buffer-menu-2 () | |
882 (let ((max-buffer-name-length 0) | |
883 file-buffers | |
884 function-info-vector) | |
885 ;; Calculate the longest buffer name. | |
886 (mapc | |
20901 | 887 (lambda (buffer) |
888 (if (or msb-display-invisible-buffers-p | |
889 (not (msb-invisible-buffer-p))) | |
890 (setq max-buffer-name-length | |
891 (max max-buffer-name-length | |
892 (length (buffer-name buffer)))))) | |
10228 | 893 (buffer-list)) |
894 ;; Make a list with elements of type | |
895 ;; (BUFFER-LIST-VARIABLE | |
896 ;; CONDITION | |
897 ;; MENU-SORT-KEY | |
898 ;; MENU-TITLE | |
899 ;; ITEM-HANDLER | |
900 ;; SORTER) | |
901 ;; Uses "function-global" variables: | |
902 ;; function-info-vector | |
903 (setq function-info-vector | |
904 (apply (function vector) | |
905 (mapcar (function msb--create-function-info) | |
20901 | 906 (append msb-menu-cond (msb--mode-menu-cond))))) |
10228 | 907 ;; Split the buffer-list into several lists; one list for each |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
908 ;; criteria. This is the most critical part with respect to time. |
20901 | 909 (mapc (lambda (buffer) |
910 (cond ((and msb-files-by-directory | |
911 (buffer-file-name buffer) | |
912 ;; exclude ange-ftp buffers | |
913 ;;(not (string-match "\\/[^/:]+:" | |
914 ;; (buffer-file-name buffer))) | |
915 ) | |
916 (push buffer file-buffers)) | |
917 (t | |
918 (msb--choose-menu buffer | |
919 function-info-vector | |
920 max-buffer-name-length)))) | |
10228 | 921 (buffer-list)) |
922 (when file-buffers | |
923 (setq file-buffers | |
20901 | 924 (mapcar (lambda (buffer-list) |
925 (cons msb-files-by-directory-sort-key | |
926 (cons (car buffer-list) | |
927 (sort | |
928 (mapcar (function | |
929 (lambda (buffer) | |
930 (cons (save-excursion | |
931 (set-buffer buffer) | |
932 (funcall msb-item-handling-function | |
933 buffer | |
934 max-buffer-name-length)) | |
935 buffer))) | |
936 (cdr buffer-list)) | |
937 (function | |
938 (lambda (item1 item2) | |
939 (string< (car item1) (car item2)))))))) | |
10228 | 940 (msb--choose-file-menu file-buffers)))) |
941 ;; Now make the menu - a list of (TITLE . BUFFER-LIST) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
942 (let* (menu |
10228 | 943 (most-recently-used |
944 (msb--most-recently-used-menu max-buffer-name-length)) | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
945 (others (nconc file-buffers |
10228 | 946 (loop for elt |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
947 across function-info-vector |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
948 for value = (msb--create-sort-item elt) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
949 if value collect value)))) |
10228 | 950 (setq menu |
951 (mapcar 'cdr ;Remove the SORT-KEY | |
952 ;; Sort the menus - not the items. | |
953 (msb--add-separators | |
954 (sort | |
955 ;; Get a list of (SORT-KEY TITLE . BUFFER-LIST) | |
956 ;; Also sorts the items within the menus. | |
957 (if (cdr most-recently-used) | |
958 (cons | |
959 ;; Add most recent used buffers | |
960 (cons msb-most-recently-used-sort-key | |
961 most-recently-used) | |
962 others) | |
963 others) | |
20901 | 964 (lambda (elt1 elt2) |
965 (< (car elt1) (car elt2))))))) | |
10228 | 966 ;; Now make it a keymap menu |
967 (append | |
968 '(keymap "Select Buffer") | |
969 (msb--make-keymap-menu menu) | |
970 (when msb-separator-diff | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
971 (list (list 'separator "--"))) |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
972 (list (cons 'toggle |
10228 | 973 (cons |
974 (if msb-files-by-directory | |
975 "*Files by type*" | |
976 "*Files by directory*") | |
977 'msb--toggle-menu-type))))))) | |
978 | |
979 (defun msb--create-buffer-menu () | |
980 (save-match-data | |
981 (save-excursion | |
982 (msb--create-buffer-menu-2)))) | |
983 | |
984 ;;; | |
985 ;;; Multi purpose function for selecting a buffer with the mouse. | |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
986 ;;; |
10228 | 987 (defun msb--toggle-menu-type () |
988 (interactive) | |
989 (setq msb-files-by-directory (not msb-files-by-directory)) | |
20884
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
990 ;; This gets a warning, but it is correct, |
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
991 ;; because this file redefines menu-bar-update-buffers. |
91f9c828fc1a
(msb--choose-file-menu): Save some debugging info.
Richard M. Stallman <rms@gnu.org>
parents:
20758
diff
changeset
|
992 (menu-bar-update-buffers t)) |
10228 | 993 |
994 (defun mouse-select-buffer (event) | |
995 "Pop up several menus of buffers, for selection with the mouse. | |
996 Returns the selected buffer or nil if no buffer is selected. | |
997 | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
998 The way the buffers are split is conveniently handled with the |
10239
52a1e5ef144c
Fix quoting conventions and spaces at end of sentence.
Richard M. Stallman <rms@gnu.org>
parents:
10228
diff
changeset
|
999 variable `msb-menu-cond'." |
10228 | 1000 ;; Popup the menu and return the selected buffer. |
1001 (when (or msb--error | |
1002 (not msb--last-buffer-menu) | |
1003 (not (fboundp 'frame-or-buffer-changed-p)) | |
1004 (frame-or-buffer-changed-p)) | |
1005 (setq msb--error nil) | |
1006 (setq msb--last-buffer-menu (msb--create-buffer-menu))) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1007 (let ((position event) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1008 choice) |
10228 | 1009 (when (and (fboundp 'posn-x-y) |
1010 (fboundp 'posn-window)) | |
1011 (let ((posX (car (posn-x-y (event-start event)))) | |
1012 (posY (cdr (posn-x-y (event-start event)))) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1013 (posWind (posn-window (event-start event)))) |
10228 | 1014 ;; adjust position |
1015 (setq posX (- posX (funcall msb-horizontal-shift-function)) | |
1016 position (list (list posX posY) posWind)))) | |
10823
abd2a268ed88
(mouse-select-buffer): Do sit-for before x-popup-menu.
Richard M. Stallman <rms@gnu.org>
parents:
10821
diff
changeset
|
1017 ;; This `sit-for' magically makes the menu stay up if the mouse |
13998
2f2d3995b57f
(msb-max-file-menu-items, msb-menu-cond): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13372
diff
changeset
|
1018 ;; button is released within 0.1 second. |
10823
abd2a268ed88
(mouse-select-buffer): Do sit-for before x-popup-menu.
Richard M. Stallman <rms@gnu.org>
parents:
10821
diff
changeset
|
1019 (sit-for 0 100) |
abd2a268ed88
(mouse-select-buffer): Do sit-for before x-popup-menu.
Richard M. Stallman <rms@gnu.org>
parents:
10821
diff
changeset
|
1020 ;; Popup the menu |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1021 (setq choice (x-popup-menu position msb--last-buffer-menu)) |
10228 | 1022 (cond |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1023 ((eq (car choice) 'toggle) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1024 ;; Bring up the menu again with type toggled. |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1025 (msb--toggle-menu-type) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1026 (mouse-select-buffer event)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1027 ((and (numberp (car choice)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1028 (null (cdr choice))) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1029 (let ((msb--last-buffer-menu (nthcdr 3 (assq (car choice) msb--last-buffer-menu)))) |
10228 | 1030 (mouse-select-buffer event))) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1031 ((while (numberp (car choice)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1032 (setq choice (cdr choice)))) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1033 ((and (stringp (car choice)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1034 (null (cdr choice))) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1035 (car choice)) |
10403
c0e27466fb3f
(mouse-select-buffer) Handle an aborted selection.
Richard M. Stallman <rms@gnu.org>
parents:
10371
diff
changeset
|
1036 ((null choice) |
c0e27466fb3f
(mouse-select-buffer) Handle an aborted selection.
Richard M. Stallman <rms@gnu.org>
parents:
10371
diff
changeset
|
1037 choice) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1038 (t |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1039 (error "Unknown form for buffer: %s" choice))))) |
20901 | 1040 |
10228 | 1041 ;; Add separators |
1042 (defun msb--add-separators (sorted-list) | |
1043 (cond | |
1044 ((or (not msb-separator-diff) | |
1045 (not (numberp msb-separator-diff))) | |
1046 sorted-list) | |
1047 (t | |
1048 (let ((last-key nil)) | |
1049 (mapcan | |
20901 | 1050 (lambda (item) |
1051 (cond | |
1052 ((and msb-separator-diff | |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1053 last-key |
20901 | 1054 (> (- (car item) last-key) |
1055 msb-separator-diff)) | |
1056 (setq last-key (car item)) | |
1057 (list (cons last-key 'separator) | |
1058 item)) | |
1059 (t | |
1060 (setq last-key (car item)) | |
1061 (list item)))) | |
10228 | 1062 sorted-list))))) |
1063 | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1064 (defun msb--split-menus-2 (list mcount result) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1065 (cond |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1066 ((> (length list) msb-max-menu-items) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1067 (let ((count 0) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1068 sub-name |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1069 (tmp-list nil)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1070 (while (< count msb-max-menu-items) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1071 (push (pop list) tmp-list) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1072 (incf count)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1073 (setq tmp-list (nreverse tmp-list)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1074 (setq sub-name (concat (car (car tmp-list)) "...")) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1075 (push (nconc (list mcount sub-name |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1076 'keymap sub-name) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1077 tmp-list) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1078 result)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1079 (msb--split-menus-2 list (1+ mcount) result)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1080 ((null result) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1081 list) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1082 (t |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1083 (let (sub-name) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1084 (setq sub-name (concat (car (car list)) "...")) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1085 (push (nconc (list mcount sub-name |
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1086 'keymap sub-name) |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1087 list) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1088 result)) |
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1089 (nreverse result)))) |
20901 | 1090 |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1091 (defun msb--split-menus (list) |
20901 | 1092 (if (and (integerp msb-max-menu-items) |
1093 (> msb-max-menu-items 0)) | |
1094 (msb--split-menus-2 list 0 nil) | |
1095 list)) | |
10371
629821e2b42e
Better format of files-by-directory menus.
Richard M. Stallman <rms@gnu.org>
parents:
10239
diff
changeset
|
1096 |
10228 | 1097 (defun msb--make-keymap-menu (raw-menu) |
1098 (let ((end (cons '(nil) 'menu-bar-select-buffer)) | |
1099 (mcount 0)) | |
1100 (mapcar | |
20901 | 1101 (lambda (sub-menu) |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1102 (cond |
20901 | 1103 ((eq 'separator sub-menu) |
1104 (list 'separator "--")) | |
1105 (t | |
1106 (let ((buffers (mapcar (function | |
1107 (lambda (item) | |
1108 (let ((string (car item)) | |
1109 (buffer (cdr item))) | |
1110 (cons (buffer-name buffer) | |
1111 (cons string end))))) | |
1112 (cdr sub-menu)))) | |
1113 (nconc (list (incf mcount) (car sub-menu) | |
1114 'keymap (car sub-menu)) | |
1115 (msb--split-menus buffers)))))) | |
10228 | 1116 raw-menu))) |
1117 | |
1118 (defun menu-bar-update-buffers (&optional arg) | |
1119 ;; If user discards the Buffers item, play along. | |
1120 (when (and (lookup-key (current-global-map) [menu-bar buffer]) | |
1121 (or (not (fboundp 'frame-or-buffer-changed-p)) | |
1122 (frame-or-buffer-changed-p) | |
1123 arg)) | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1124 (let ((frames (frame-list)) |
10228 | 1125 buffers-menu frames-menu) |
1126 ;; Make the menu of buffers proper. | |
1127 (setq msb--last-buffer-menu (msb--create-buffer-menu)) | |
1128 (setq buffers-menu msb--last-buffer-menu) | |
1129 ;; Make a Frames menu if we have more than one frame. | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1130 (when (cdr frames) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1131 (let* ((frame-length (length frames)) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1132 (f-title (format "Frames (%d)" frame-length))) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1133 ;; List only the N most recently selected frames |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1134 (when (and (integerp msb-max-menu-items) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1135 (> msb-max-menu-items 1) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1136 (> frame-length msb-max-menu-items)) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1137 (setcdr (nthcdr msb-max-menu-items frames) nil)) |
10228 | 1138 (setq frames-menu |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1139 (nconc |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1140 (list 'frame f-title '(nil) 'keymap f-title) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1141 (mapcar |
20901 | 1142 (lambda (frame) |
1143 (nconc | |
1144 (list frame | |
1145 (cdr (assq 'name | |
1146 (frame-parameters frame))) | |
1147 (cons nil nil)) | |
1148 'menu-bar-select-frame)) | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1149 frames))))) |
10228 | 1150 (define-key (current-global-map) [menu-bar buffer] |
1151 (cons "Buffers" | |
1152 (if (and buffers-menu frames-menu) | |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1153 ;; Combine Frame and Buffers menus with separator between |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1154 (nconc (list 'keymap "Buffers and Frames" frames-menu |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1155 (and msb-separator-diff '(separator "--"))) |
10821
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1156 (cddr buffers-menu)) |
1ff0ed96a4c0
(msb): Select the window that the mouse is in before
Richard M. Stallman <rms@gnu.org>
parents:
10403
diff
changeset
|
1157 (or buffers-menu 'undefined))))))) |
10228 | 1158 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1159 ;; Snarf current bindings of `mouse-buffer-menu' (normally |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1160 ;; C-down-mouse-1). |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1161 (defvar msb-mode-map |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1162 (let ((map (make-sparse-keymap))) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1163 (mapcar (lambda (key) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1164 (define-key map key #'msb)) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1165 (where-is-internal 'mouse-buffer-menu (make-sparse-keymap))) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1166 map)) |
20504
1b8aec1c12f1
Doc fixes. Changed `append' to `nconc'
Richard M. Stallman <rms@gnu.org>
parents:
16833
diff
changeset
|
1167 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1168 ;;;###autoload |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1169 (defun msb-mode (&optional arg) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1170 "Toggle Msb mode. |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1171 With arg, turn Msb mode on if and only if arg is positive. |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1172 This mode overrides the binding(s) of `mouse-buffer-menu' to provide a |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1173 different buffer menu using the function `msb'." |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1174 (interactive "P") |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1175 (setq msb-mode (if arg |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1176 (> (prefix-numeric-value arg) 0) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1177 (not msb-mode))) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1178 (if msb-mode |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1179 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers) |
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1180 (remove-hook 'menu-bar-update-hook 'menu-bar-update-buffers))) |
10228 | 1181 |
24796
19424321d8e1
Add to minor-mode-map-alist. Remove hook installation
Dave Love <fx@gnu.org>
parents:
21670
diff
changeset
|
1182 (add-to-list 'minor-mode-map-alist (cons 'msb-mode msb-mode-map)) |
10228 | 1183 |
1184 (provide 'msb) | |
1185 (eval-after-load 'msb (run-hooks 'msb-after-load-hooks)) | |
16833
052a9f2e21e5
(frame-or-buffer-changed-p): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16428
diff
changeset
|
1186 |
10228 | 1187 ;;; msb.el ends here |