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