Mercurial > emacs
annotate lisp/filesets.el @ 45159:58e7edaaf656
*** empty log message ***
author | Colin Walters <walters@gnu.org> |
---|---|
date | Tue, 07 May 2002 08:02:09 +0000 |
parents | c26266baaba5 |
children | 79ab9956f2a0 |
rev | line source |
---|---|
44934 | 1 ;;; filesets.el --- handle group of files |
2 | |
3 ;; Copyright (C) 2002 Free Software Foundation, Inc. | |
4 | |
44959 | 5 ;; Author: Thomas Link <t.link@gmx.at> |
44934 | 6 ;; Keywords: filesets convenience |
7 | |
44959 | 8 ;; This file is part of GNU Emacs. |
9 | |
44934 | 10 ;; This program is free software; you can redistribute it and/or modify |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; This program is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; A copy of the GNU General Public License can be obtained from this | |
21 ;; program's author or from the Free Software Foundation, Inc., 675 Mass | |
22 ;; Ave, Cambridge, MA 02139, USA. | |
23 | |
24 (defvar filesets-version "1.8.1") | |
25 (defvar filesets-homepage | |
26 "http://members.a1.net/t.link/CompEmacsFilesets.html") | |
27 | |
28 ;;; Commentary: | |
29 | |
44973 | 30 ;; Define filesets, which can be opened or saved with the power of one or |
44959 | 31 ;; two mouse clicks only. A fileset is either a list of files, a file |
32 ;; pattern, a base directory and a search pattern (for files), or an | |
33 ;; inclusion group (i.e. a base file including other files). | |
44934 | 34 |
44959 | 35 ;; Usage: 1. Put (require 'filesets) into your start-up file. 2. Type |
36 ;; M-x filesets-edit or choose "Edit Filesets" from the menu. 3. Save | |
37 ;; your customizations. | |
44934 | 38 |
44959 | 39 ;; Caveat: Fileset names have to be unique. |
44934 | 40 |
44959 | 41 ;; Filesets.el adds a nifty filesets menu to your menubar. If you change |
42 ;; your filesets on the fly, don't forget to select "Save Filesets" from | |
43 ;; the menu. | |
44934 | 44 |
44959 | 45 ;; Pressing on the first item in the submenu will open all files at once. |
46 ;; Define your own function, e.g. browse-url, for opening a fileset's | |
47 ;; files. Or define external viewers for opening files with other | |
48 ;; programs. See `filesets-external-viewers'. | |
44934 | 49 |
44959 | 50 ;; BTW, if you close a fileset, files, which have been changed, will |
51 ;; be silently saved. Change this behaviour by setting | |
52 ;; `filesets-save-buffer-fn'. | |
44934 | 53 |
54 ;;; Supported modes for inclusion groups (`filesets-ingroup-patterns'): | |
55 ;; - Elisp | |
56 ;; - Emacs-Wiki (simple names only) | |
57 ;; - LaTeX | |
58 | |
59 | |
60 | |
61 ;;; Known bugs: | |
62 | |
63 | |
64 ;;; To do: | |
65 | |
66 ;;- better handling of different customization scenarios | |
67 | |
68 | |
69 ;;; Credits: | |
70 | |
71 ;; Helpful suggestions (but no significant code) were contributed by | |
72 | |
73 ;;- Christoph Conrad (at gmx de) | |
74 ;;- Christian Ohler (at Informatik Uni-Oldenburg DE) | |
75 ;;- Richard Stallman aka RMS (at gnu org) | |
76 ;;- Per Abrahamsen aka abraham (at dina kvl dk) | |
77 | |
78 | |
79 ;;; Code: | |
80 | |
81 (eval-when-compile | |
82 (require 'cl)) | |
83 | |
84 | |
85 ;;; Some variables | |
44959 | 86 (eval-and-compile |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
87 (defvar filesets-running-xemacs (string-match "XEmacs\\|Lucid" emacs-version) |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
88 "Non-nil means we are running XEmacs.")) |
44934 | 89 |
90 (defvar filesets-menu-cache nil | |
91 "The whole filesets menu.") | |
92 (defvar filesets-cache-version nil | |
93 "Filesets' cached version number.") | |
94 (defvar filesets-cache-hostname nil | |
95 "Filesets' cached system name.") | |
96 | |
97 (defvar filesets-ingroup-cache nil | |
98 "A plist containing files and their ingroup data.") | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
99 (defvar filesets-ingroup-files nil |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
100 "List of files already processed when searching for included files.") |
44934 | 101 |
102 (defvar filesets-has-changed-flag t | |
103 "Non-nil means some fileset definition has changed.") | |
104 (defvar filesets-submenus nil | |
105 "An association list with filesets menu data.") | |
106 (defvar filesets-updated-buffers nil | |
107 "A list of buffers with updated menu bars.") | |
108 (defvar filesets-menu-use-cached-flag nil | |
109 "Use cached data. See `filesets-menu-ensure-use-cached' for details.") | |
110 (defvar filesets-update-cache-file-flag nil | |
111 "Non-nil means the cache needs updating.") | |
112 (defvar filesets-ignore-next-set-default nil | |
113 "A list of custom variables for which the next `set-default' will be | |
114 ignored.") | |
115 | |
116 (defvar filesets-output-buffer-flag nil | |
117 "Non-nil means the current buffer is an output buffer created by filesets. | |
118 Is buffer local variable.") | |
119 | |
120 (defvar filesets-verbosity 1 | |
121 "An integer defining the level of verbosity. 0 means no messages | |
122 at all.") | |
123 | |
124 (defvar filesets-menu-ensure-use-cached | |
125 (and filesets-running-xemacs | |
126 (not (emacs-version>= 21 5))) | |
127 "Make sure (X)Emacs uses filesets' cache. | |
128 | |
129 Well, if you use XEmacs (prior to 21.5?) custom.el is loaded after | |
130 init.el. This means that settings saved in the cache file (see | |
131 `filesets-menu-cache-file') will be overwritten by custom.el. In order | |
132 to ensure the use of the cache file, set this variable to t -- which is | |
133 the default for XEmacs prior to 21.5. If you want to change this value | |
134 put \"(setq filesets-menu-ensure-use-cached VALUE)\" into your startup | |
135 file -- before loading filesets.el. | |
136 | |
137 So, when should you think about setting this value to t? If filesets.el | |
138 is loaded before user customizations. Thus, if (require 'filesets) | |
139 precedes the custom-set-variables command or, for XEmacs, if init.el is | |
140 loaded before custom.el, set this variable to t.") | |
141 | |
142 | |
143 ;;; utils | |
144 (defun filesets-filter-list (lst cond-fn) | |
145 "Remove all elements not conforming to COND-FN from list LST. | |
146 COND-FN takes one argument: the current element." | |
147 ; (remove* 'dummy lst :test (lambda (dummy elt) | |
148 ; (not (funcall cond-fn elt))))) | |
149 (let ((rv nil)) | |
150 (dolist (elt lst rv) | |
151 (when (funcall cond-fn elt) | |
152 (setq rv (append rv (list elt))))))) | |
153 | |
154 (defun filesets-sublist (lst beg &optional end) | |
155 "Get the sublist of LST from BEG to END - 1." | |
156 (let ((rv nil) | |
157 (i beg) | |
158 (top (or end | |
159 (length lst)))) | |
160 (while (< i top) | |
161 (setq rv (append rv (list (nth i lst)))) | |
162 (setq i (+ i 1))) | |
163 rv)) | |
164 | |
165 (defun filesets-select-command (cmd-list) | |
166 "Select one command from CMD-LIST -- a string with space separated names." | |
167 (let ((this (shell-command-to-string | |
168 (format "which --skip-alias %s 2> /dev/null | head -n 1" | |
169 cmd-list)))) | |
170 (if (equal this "") | |
171 nil | |
172 (file-name-nondirectory (substring this 0 (- (length this) 1)))))) | |
173 | |
174 (defun filesets-which-command (cmd) | |
175 "Calls \"which CMD\"." | |
176 (shell-command-to-string (format "which %s" cmd))) | |
177 | |
178 (defun filesets-which-command-p (cmd) | |
179 "Calls \"which CMD\" and returns non-nil if the command was found." | |
180 (when (string-match (format "\\(/[^/]+\\)?/%s" cmd) | |
181 (filesets-which-command cmd)) | |
182 cmd)) | |
183 | |
184 (defun filesets-message (level &rest args) | |
185 "Show a message only if LEVEL is greater or equal then `filesets-verbosity'." | |
186 (when (<= level (abs filesets-verbosity)) | |
187 (apply 'message args))) | |
188 | |
189 | |
190 ;;; config file | |
191 (defun filesets-save-config () | |
192 "Save filesets' customizations." | |
193 (interactive) | |
194 (customize-save-customized)) | |
195 | |
196 (defun filesets-reset-fileset (&optional fileset no-cache) | |
197 "Reset the cached values for one or all filesets." | |
198 (if fileset | |
199 (setq filesets-submenus (lax-plist-put filesets-submenus fileset nil)) | |
200 (setq filesets-submenus nil)) | |
201 (setq filesets-has-changed-flag t) | |
202 (setq filesets-update-cache-file-flag (or filesets-update-cache-file-flag | |
203 (not no-cache)))) | |
204 | |
205 (defun filesets-set-config (fileset var val) | |
206 "Set-default wrapper function." | |
207 (filesets-reset-fileset fileset) | |
208 (set-default var val)) | |
209 ; (customize-set-variable var val)) | |
210 ; (filesets-build-menu)) | |
211 | |
212 (defun filesets-set-default (sym val &optional init-flag) | |
213 "Set-default wrapper function used in conjunction with `defcustom'." | |
214 (let ((ignore-flag (member sym filesets-ignore-next-set-default))) | |
215 (if ignore-flag | |
216 (setq filesets-ignore-next-set-default | |
217 (delete sym filesets-ignore-next-set-default)) | |
218 (if init-flag | |
219 (custom-initialize-set sym val) | |
220 (set-default sym val))) | |
221 (not ignore-flag))) | |
222 | |
223 (defun filesets-set-default! (sym val) | |
224 "Call `filestes-set-default' and reset cached data (i.e. rebuild menu)." | |
225 (when (filesets-set-default sym val) | |
226 (filesets-reset-fileset))) | |
227 | |
228 (defun filesets-set-default+ (sym val) | |
229 "Call `filestes-set-default' and reset filesets' standard menu." | |
230 (when (filesets-set-default sym val) | |
231 (setq filesets-has-changed-flag t))) | |
232 ; (filesets-reset-fileset nil t))) | |
233 | |
234 (defun filesets-data-set-default (sym val) | |
235 "Set the default for `filesets-data'." | |
236 (if filesets-menu-use-cached-flag | |
237 (setq filesets-menu-use-cached-flag nil) | |
238 (when (default-boundp 'filesets-data) | |
239 (let ((modified-filesets | |
240 (filesets-filter-list val | |
241 (lambda (x) | |
242 (let ((name (car x)) | |
243 (data (cdr x))) | |
244 (let ((elt (assoc name filesets-data))) | |
245 (or (not elt) | |
246 (not (equal data (cdr elt)))))))))) | |
247 (dolist (x modified-filesets) | |
248 (filesets-reset-fileset (car x)))))) | |
249 (filesets-set-default sym val)) | |
250 | |
251 | |
252 | |
253 ;;; configuration | |
254 (defgroup filesets nil | |
255 "The fileset swapper." | |
256 :prefix "filesets-" | |
257 :group 'convenience) | |
258 | |
259 (defcustom filesets-menu-name "Filesets" | |
260 "*Filesets' menu name." | |
261 :set (function filesets-set-default) | |
262 :type 'sexp | |
263 :group 'filesets) | |
264 | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
265 (when filesets-running-xemacs |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
266 (defcustom filesets-menu-path nil |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
267 "*The menu under which the filesets menu should be inserted. |
44934 | 268 XEmacs specific; see `add-submenu' for documentation." |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
269 :set (function filesets-set-default) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
270 :type 'sexp |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
271 :group 'filesets) |
44934 | 272 |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
273 (defcustom filesets-menu-before "File" |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
274 "*The name of a menu before which this menu should be added. |
44934 | 275 XEmacs specific; see `add-submenu' for documentation." |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
276 :set (function filesets-set-default) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
277 :type 'sexp |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
278 :group 'filesets) |
44934 | 279 |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
280 (defcustom filesets-menu-in-menu nil |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
281 "*Use that instead of `current-menubar' as the menu to change. |
44934 | 282 XEmacs specific; see `add-submenu' for documentation." |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
283 :set (function filesets-set-default) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
284 :type 'sexp |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
285 :group 'filesets)) |
44934 | 286 |
287 (defcustom filesets-menu-shortcuts-flag t | |
288 "*Non-nil means to prepend menus with hopefully unique shortcuts." | |
289 :set (function filesets-set-default!) | |
290 :type 'boolean | |
291 :group 'filesets) | |
292 | |
293 (defcustom filesets-menu-shortcuts-marker "%_" | |
294 "*String for marking menu shortcuts." | |
295 :set (function filesets-set-default!) | |
296 :type 'string | |
297 :group 'filesets) | |
298 | |
299 ;(defcustom filesets-menu-cnvfp-flag nil | |
300 ; "*Non-nil means show \"Convert :pattern to :files\" entry for :pattern menus." | |
301 ; :set (function filesets-set-default!) | |
302 ; :type 'boolean | |
303 ; :group 'filesets) | |
304 | |
305 (defcustom filesets-menu-cache-file | |
306 (if filesets-running-xemacs | |
307 "~/.xemacs/filesets-cache.el" | |
308 "~/.filesets-cache.el") | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
309 "*File to be used for saving the filesets menu between sessions. |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
310 Set this to \"\", to disable caching of menus. |
44934 | 311 Don't forget to check out `filesets-menu-ensure-use-cached'." |
312 :set (function filesets-set-default) | |
313 :type 'file | |
314 :group 'filesets) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
315 (put 'filesets-menu-cache-file 'risky-local-variable t) |
44934 | 316 |
317 (defcustom filesets-menu-cache-contents | |
318 '(filesets-be-docile-flag | |
319 filesets-submenus | |
320 filesets-menu-cache | |
321 filesets-ingroup-cache) | |
322 "*Stuff we want to save in `filesets-menu-cache-file'. | |
323 | |
324 Possible uses: don't save configuration data in the main startup files | |
325 but in filesets's own cache. In this case add `filesets-data' to this | |
326 list. | |
327 | |
328 There is a second reason for putting `filesets-data' on this list. If | |
329 you frequently add and remove buffers on the fly to :files filesets, you | |
330 don't need to save your customizations if `filesets-data' is being | |
331 mirrored in the cache file. In this case the version in the cache file | |
332 is the current one, and the version in your startup file will be | |
333 silently updated later on. | |
334 | |
335 If you want caching to work properly, at least `filesets-submenus', | |
336 `filesets-menu-cache', and `filesets-ingroup-cache' should be in this | |
337 list. | |
338 | |
339 Don't forget to check out `filesets-menu-ensure-use-cached'." | |
340 :set (function filesets-set-default) | |
341 :type '(repeat | |
342 (choice :tag "Variable" | |
343 (const :tag "filesets-submenus" | |
344 :value filesets-submenus) | |
345 (const :tag "filesets-menu-cache" | |
346 :value filesets-menu-cache) | |
347 (const :tag "filesets-ingroup-cache" | |
348 :value filesets-ingroup-cache) | |
349 (const :tag "filesets-data" | |
350 :value filesets-data) | |
351 (const :tag "filesets-external-viewers" | |
352 :value filesets-external-viewers) | |
353 (const :tag "filesets-ingroup-patterns" | |
354 :value filesets-ingroup-patterns) | |
355 (const :tag "filesets-be-docile-flag" | |
356 :value filesets-be-docile-flag) | |
357 (sexp :tag "Other" :value nil))) | |
358 :group 'filesets) | |
359 | |
360 (defcustom filesets-cache-fill-content-hooks nil | |
361 "*Hooks to run when writing the contents of filesets' cache file. | |
362 | |
363 The hook is called with the cache file as current buffer and the cursor | |
364 at the last position. I.e. each hook has to make sure that the cursor is | |
365 at the last position. | |
366 | |
367 Possible uses: If you don't want to save `filesets-data' in your normal | |
368 configuration file, you can add a something like this | |
369 | |
370 \(lambda () | |
371 \(insert (format \"(setq-default filesets-data '%S)\" | |
372 filesets-data)) | |
373 \(newline 2)) | |
374 | |
375 to this hook. | |
376 | |
377 Don't forget to check out `filesets-menu-ensure-use-cached'." | |
378 :set (function filesets-set-default) | |
379 :type 'hook | |
380 :group 'filesets) | |
381 | |
382 (defcustom filesets-cache-hostname-flag nil | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
383 "*Non-nil means cache the hostname. |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
384 If the current name differs from the cached one, |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
385 rebuild the menu and create a new cache file." |
44934 | 386 :set (function filesets-set-default) |
387 :type 'boolean | |
388 :group 'filesets) | |
389 | |
390 (defcustom filesets-cache-save-often-flag nil | |
391 "*Non-nil means save buffer on every change of the filesets menu. | |
392 If this variable is set to nil and if Emacs crashes, the cache and | |
393 filesets-data could get out of sync. Set this to t if this happens from | |
394 time to time or if the fileset cache causes troubles." | |
395 :set (function filesets-set-default) | |
396 :type 'boolean | |
397 :group 'filesets) | |
398 | |
399 (defcustom filesets-max-submenu-length 25 | |
400 "*Maximum length of submenus. | |
401 Set this value to 0 to turn menu splitting off. BTW, parts of submenus | |
402 will not be rewrapped if their length exceeds this value." | |
403 :set (function filesets-set-default) | |
404 :type 'integer | |
405 :group 'filesets) | |
406 | |
407 (defcustom filesets-max-entry-length 50 | |
408 "*Truncate names of splitted submenus to this length." | |
409 :set (function filesets-set-default) | |
410 :type 'integer | |
411 :group 'filesets) | |
412 | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
413 (defcustom filesets-browse-dir-function 'dired |
44934 | 414 "*A function or command used for browsing directories. |
415 When using an external command, \"%s\" will be replaced with the | |
416 directory's name. | |
417 | |
418 Note: You have to manually rebuild the menu if you change this value." | |
419 :set (function filesets-set-default) | |
420 :type '(choice :tag "Function:" | |
421 (const :tag "dired" | |
422 :value dired) | |
423 (list :tag "Command" | |
424 :value ("" "%s") | |
425 (string :tag "Name") | |
426 (string :tag "Arguments")) | |
427 (function :tag "Function" | |
428 :value nil)) | |
429 :group 'filesets) | |
430 | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
431 (defcustom filesets-open-file-function 'filesets-find-or-display-file |
44934 | 432 "*The function used for opening files. |
433 | |
434 `filesets-find-or-display-file' ... Filesets' default function for | |
435 visiting files. This function checks if an external viewer is defined | |
436 for a specific file type. Either this viewer, if defined, or | |
437 `find-file' will be used to visit a file. | |
438 | |
439 `filesets-find-file' ... An alternative function that always uses | |
440 `find-file'. If `filesets-be-docile-flag' is true, a file, which isn't | |
441 readable, will not be opened. | |
442 | |
443 Caveat: Changes will take effect only after rebuilding the menu." | |
444 :set (function filesets-set-default) | |
445 :type '(choice :tag "Function:" | |
446 (const :tag "filesets-find-or-display-file" | |
447 :value filesets-find-or-display-file) | |
448 (const :tag "filesets-find-file" | |
449 :value filesets-find-file) | |
450 (function :tag "Function" | |
451 :value nil)) | |
452 :group 'filesets) | |
453 | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
454 (defcustom filesets-save-buffer-function 'save-buffer |
44934 | 455 "*The function used to save a buffer. |
456 Caveat: Changes will take effect after rebuilding the menu." | |
457 :set (function filesets-set-default) | |
458 :type '(choice :tag "Function:" | |
459 (const :tag "save-buffer" | |
460 :value save-buffer) | |
461 (function :tag "Function" | |
462 :value nil)) | |
463 :group 'filesets) | |
464 | |
465 (defcustom filesets-find-file-delay | |
466 (if (and filesets-running-xemacs gutter-buffers-tab-visible-p) | |
467 0.5 | |
468 0) | |
469 "*Delay before calling find-file. | |
470 This is for calls via `filesets-find-or-display-file' | |
471 or `filesets-find-file'. | |
472 | |
473 Set this to 0, if you don't use XEmacs' buffer tabs." | |
474 :set (function filesets-set-default) | |
475 :type 'number | |
476 :group 'filesets) | |
477 | |
478 (defcustom filesets-be-docile-flag nil | |
479 "*Non-nil means don't complain if a file or a directory doesn't exist. | |
480 This is useful if you want to use the same startup files in different | |
481 computer environments." | |
482 :set (function filesets-set-default) | |
483 :type 'boolean | |
484 :group 'filesets) | |
485 | |
486 (defcustom filesets-sort-menu-flag t | |
487 "*Non-nil means sort the filesets menu alphabetically." | |
488 :set (function filesets-set-default) | |
489 :type 'boolean | |
490 :group 'filesets) | |
491 | |
492 (defcustom filesets-sort-case-sensitive-flag t | |
493 "*Non-nil means sorting of the filesete menu is case sensitive." | |
494 :set (function filesets-set-default) | |
495 :type 'boolean | |
496 :group 'filesets) | |
497 | |
498 (defcustom filesets-tree-max-level 3 | |
499 "*Maximum scan depth for directory trees. | |
500 A :tree fileset is defined by a base directory the contents of which | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
501 will be recursively added to the menu. `filesets-tree-max-level' tells up |
44934 | 502 to which level the directory structure should be scanned/listed, |
503 i.e. how deep the menu should be. Try something like | |
504 | |
505 \(\"HOME -- only one level\" | |
506 \(:tree \"~\" \"^[^.].*[^~]$\") | |
507 \(:tree-max-level 1) | |
508 \(:filter-dirs-flag t)) | |
509 \(\"HOME -- up to 3 levels\" | |
510 \(:tree \"~\" \"^[^.].*[^~]$\") | |
511 \(:tree-max-level 3) | |
512 \(:filter-dirs-flag t)) | |
513 | |
514 and it should become clear what this option is about. In any case, | |
515 including directory trees to the menu can take a lot of memory." | |
516 :set (function filesets-set-default) | |
517 :type 'integer | |
518 :group 'filesets) | |
519 | |
520 (defcustom filesets-commands | |
521 `(("Query Replace" | |
522 query-replace | |
523 (filesets-cmd-query-replace-getargs)) | |
524 ("Query Replace (regexp)" | |
525 query-replace-regexp | |
526 (filesets-cmd-query-replace-getargs)) | |
527 ("Grep <<selection>>" | |
528 "grep" | |
529 ("-n " filesets-get-quoted-selection " " "<<file-name>>")) | |
530 ("Run Shell Command" | |
531 filesets-cmd-shell-command | |
532 (filesets-cmd-shell-command-getargs))) | |
533 "*Commands to run on filesets. | |
534 An association list of names, functions, and an argument list (or a | |
535 function that returns one) to be run on a filesets' files. | |
536 | |
537 The argument <file-name> or <<file-name>> (quoted) will be replaced with | |
538 the filename." | |
539 :set (function filesets-set-default+) | |
540 :type '(repeat :tag "Commands" | |
541 (list :tag "Definition" :value ("") | |
542 (string "Name") | |
543 (choice :tag "Command" | |
544 (string :tag "String") | |
545 (function :tag "Function")) | |
546 (repeat :tag "Argument List" | |
547 (choice :tag "Arguments" | |
548 (sexp :tag "Sexp" | |
549 :value nil) | |
550 (string :tag "File Name" | |
551 :value "<file-name>") | |
552 (string :tag "Quoted File Name" | |
553 :value "<<file-name>>") | |
554 (function :tag "Function" | |
555 :value nil))))) | |
556 :group 'filesets) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
557 (put 'filesets-commands 'risky-local-variable t) |
44934 | 558 |
559 (defcustom filesets-external-viewers | |
560 (let | |
561 ; ((ps-cmd (or (and (boundp 'my-ps-viewer) my-ps-viewer) | |
562 ; (filesets-select-command "ggv gv"))) | |
563 ; (pdf-cmd (or (and (boundp 'my-ps-viewer) my-pdf-viewer) | |
564 ; (filesets-select-command "xpdf acroread"))) | |
565 ; (dvi-cmd (or (and (boundp 'my-ps-viewer) my-dvi-viewer) | |
566 ; (filesets-select-command "xdvi tkdvi"))) | |
567 ; (doc-cmd (or (and (boundp 'my-ps-viewer) my-doc-viewer) | |
568 ; (filesets-select-command "antiword"))) | |
569 ; (pic-cmd (or (and (boundp 'my-ps-viewer) my-pic-viewer) | |
570 ; (filesets-select-command "gqview ee display")))) | |
571 ((ps-cmd "ggv") | |
572 (pdf-cmd "xpdf") | |
573 (dvi-cmd "xdvi") | |
574 (doc-cmd "antiword") | |
575 (pic-cmd "gqview")) | |
576 `(("^.+\\..?html?$" browse-url | |
577 ((:ignore-on-open-all t))) | |
578 ("^.+\\.pdf$" ,pdf-cmd | |
579 ((:ignore-on-open-all t) | |
580 (:ignore-on-read-text t) | |
581 (:constraint-flag ,pdf-cmd))) | |
582 ("^.+\\.e?ps\\(.gz\\)?$" ,ps-cmd | |
583 ((:ignore-on-open-all t) | |
584 (:ignore-on-read-text t) | |
585 (:constraint-flag ,ps-cmd))) | |
586 ("^.+\\.dvi$" ,dvi-cmd | |
587 ((:ignore-on-open-all t) | |
588 (:ignore-on-read-text t) | |
589 (:constraint-flag ,dvi-cmd))) | |
590 ("^.+\\.doc$" ,doc-cmd | |
591 ((:capture-output t) | |
592 (:ignore-on-read-text t) | |
593 (:constraint-flag ,doc-cmd))) | |
594 ("^.+\\.\\(tiff\\|xpm\\|gif\\|pgn\\)$" ,pic-cmd | |
595 ((:ignore-on-open-all t) | |
596 (:ignore-on-read-text t) | |
597 (:constraint-flag ,pic-cmd))))) | |
598 "*Association list of file patterns and external viewers for use with | |
599 `filesets-find-or-display-file'. | |
600 | |
601 Has the form ((FILE-PATTERN VIEWER PROPERTIES) ...), VIEWER being either a | |
602 function or a command name as string. | |
603 | |
604 Properties is an association list determining filesets' behaviour in | |
605 several conditions. Choose one from this list: | |
606 | |
607 :ignore-on-open-all ... Don't open files of this type automatically -- | |
608 i.e. on open-all-files-events or when running commands | |
609 | |
610 :capture-output ... capture an external viewer output | |
611 | |
612 :constraintp FUNCTION ... use this viewer only if FUNCTION returns non-nil | |
613 | |
614 :constraint-flag SYMBOL ... use this viewer only if SYMBOL is non-nil | |
615 | |
616 :open-hook HOOK ... run hooks after spawning the viewer -- mainly useful | |
617 in conjunction with :capture-output | |
618 | |
619 :args (FORMAT-STRING or SYMBOL or FUNCTION) ... a list of arguments | |
620 \(defaults to (list \"%S\")) when using shell commands | |
621 | |
622 Avoid modifying this variable and achieve minor speed-ups by setting the | |
623 variables my-ps-viewer, my-pdf-viewer, my-dvi-viewer, my-pic-viewer. | |
624 | |
625 In order to view pdf or rtf files in an Emacs buffer, you could use these: | |
626 | |
627 | |
628 \(\"^.+\\.pdf$\" \"pdftotext\" | |
629 \((:capture-output t) | |
630 \(:args (\"%S - | fmt -w \" window-width)) | |
631 \(:ignore-on-read-text t) | |
632 \(:constraintp (lambda () | |
633 \(and \(filesets-which-command-p \"pdftotext\") | |
634 \(filesets-which-command-p \"fmt\")))))) | |
635 \(\"^.+\\.rtf$\" \"rtf2htm\" | |
636 \((:capture-output t) | |
637 \(:args (\"%S 2> /dev/null | w3m -dump -T text/html\")) | |
638 \(:ignore-on-read-text t) | |
639 \(:constraintp (lambda () | |
640 \(and (filesets-which-command-p \"rtf2htm\") | |
641 \(filesets-which-command-p \"w3m\")))))) | |
642 " | |
643 :set (function filesets-set-default) | |
644 :type '(repeat :tag "Viewer" | |
645 (list :tag "Definition" | |
646 :value ("^.+\\.suffix$" "") | |
647 (regexp :tag "Pattern") | |
648 (choice :tag "Viewer" | |
649 (symbol :tag "Function" :value nil) | |
650 (string :tag "Program" :value "")) | |
651 (repeat :tag "Properties" | |
652 (choice | |
653 (list :tag ":constraintp" | |
654 :value (:constraintp) | |
655 (const :format "" | |
656 :value :constraintp) | |
657 (function :tag "Function")) | |
658 (list :tag ":constraint-flag" | |
659 :value (:constraint-flag) | |
660 (const :format "" | |
661 :value :constraint-flag) | |
662 (symbol :tag "Symbol")) | |
663 (list :tag ":ignore-on-open-all" | |
664 :value (:ignore-on-open-all t) | |
665 (const :format "" | |
666 :value :ignore-on-open-all) | |
667 (boolean :tag "Boolean")) | |
668 (list :tag ":ignore-on-read-text" | |
669 :value (:ignore-on-read-text t) | |
670 (const :format "" | |
671 :value :ignore-on-read-text) | |
672 (boolean :tag "Boolean")) | |
673 (list :tag ":args" | |
674 :value (:args) | |
675 (const :format "" | |
676 :value :args) | |
677 (repeat :tag "List" | |
678 (choice :tag "Arguments" | |
679 (string :tag "String" | |
680 :value "") | |
681 (symbol :tag "Symbol" | |
682 :value nil) | |
683 (function :tag "Function" | |
684 :value nil)))) | |
685 (list :tag ":open-hook" | |
686 :value (:open-hook) | |
687 (const :format "" | |
688 :value :open-hook) | |
689 (hook :tag "Hook")) | |
690 ; (list :tag ":close-hook" | |
691 ; :value (:close-hook) | |
692 ; (const :format "" | |
693 ; :value :close-hook) | |
694 ; (hook :tag "Hook")) | |
695 (list :tag ":capture-output" | |
696 :value (:capture-output t) | |
697 (const :format "" | |
698 :value :capture-output) | |
699 (boolean :tag "Boolean")))))) | |
700 :group 'filesets) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
701 (put 'filesets-external-viewers 'risky-local-variable t) |
44934 | 702 |
703 (defcustom filesets-ingroup-patterns | |
704 '(("^.+\\.tex$" t | |
705 (((:name "Package") | |
706 (:pattern "\\\\usepackage\\W*\\(\\[[^\]]*\\]\\W*\\)?{\\W*\\(.+\\)\\W*}") | |
707 (:match-number 2) | |
708 (:stub-flag t) | |
709 (:get-file-name (lambda (master file) | |
710 (filesets-which-file master | |
711 (concat file ".sty") | |
712 (filesets-convert-path-list | |
713 (or (getenv "MY_TEXINPUTS") | |
714 (getenv "TEXINPUTS"))))))) | |
715 ((:name "Include") | |
716 (:pattern "\\\\include\\W*{\\W*\\(.+\\)\\W*}") | |
717 (:get-file-name (lambda (master file) | |
718 (filesets-which-file master | |
719 (concat file ".tex") | |
720 (filesets-convert-path-list | |
721 (or (getenv "MY_TEXINPUTS") | |
722 (getenv "TEXINPUTS")))))) | |
723 (:scan-depth 5)) | |
724 ((:name "Input") | |
725 (:pattern "\\\\input\\W*{\\W*\\(.+\\)\\W*}") | |
726 (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b)))) | |
727 (:get-file-name (lambda (master file) | |
728 (filesets-which-file master | |
729 (concat file ".tex") | |
730 (filesets-convert-path-list | |
731 (or (getenv "MY_TEXINPUTS") | |
732 (getenv "TEXINPUTS")))))) | |
733 (:scan-depth 5)) | |
734 ((:name "Bibliography") | |
735 (:pattern "\\\\bibliography\\W*{\\W*\\(.+\\)\\W*}") | |
736 (:get-file-name (lambda (master file) | |
737 (filesets-which-file master | |
738 (concat file ".bib") | |
739 (filesets-convert-path-list | |
740 (or (getenv "MY_BIBINPUTS") | |
741 (getenv "BIBINPUTS"))))))))) | |
742 ("^.+\\.el$" t | |
743 (((:name "Require") | |
744 (:pattern "(require\\W+'\\(.+\\))") | |
745 (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b)))) | |
746 (:get-file-name (lambda (master file) | |
747 (filesets-which-file master | |
748 (concat file ".el") | |
749 load-path)))) | |
750 ((:name "Load") | |
751 (:pattern "(load\\(-library\\)?\\W+\"\\(.+\\)\")") | |
752 (:match-number 2) | |
753 (:get-file-name (lambda (master file) | |
754 (filesets-which-file master file load-path)))))) | |
755 ("^\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)$" t | |
756 (((:pattern "\\<\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)\\>") | |
757 (:scan-depth 5) | |
758 (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b)))) | |
759 (:case-sensitive t) | |
760 (:get-file-name (lambda (master file) | |
761 (filesets-which-file | |
762 master | |
763 file | |
764 (if (boundp 'emacs-wiki-directories) | |
765 emacs-wiki-directories | |
766 nil)))))))) | |
767 | |
768 "*Inclusion group definitions. | |
769 | |
770 Define how to find included file according to a file's mode (being | |
771 defined by a file pattern). | |
772 | |
773 A valid entry has the form (FILE-PATTERN REMOVE-DUPLICATES-FLAG | |
774 CMD-DEF1 ...), CMD-DEF1 being a plist containing the fields :pattern | |
775 \(mandatory), :name, :get-file-name, :match-number, :scan-depth, | |
776 :preprocess, :case-sensitive. | |
777 | |
778 File Pattern ... A regexp matching the file's name for which the | |
779 following rules should be applied. | |
780 | |
781 Remove Duplicates ... If t, only the first occurrence of an included | |
782 file is retained. (See below for a full explanation.) | |
783 | |
784 :name STRING ... This pattern's name. | |
785 | |
786 :pattern REGEXP ... A regexp matching the command. This regexp has to | |
787 include a group that holds the name of the included file. | |
788 | |
789 :get-file-name FUNCTION (default: `filesets-which-file') ... A function | |
790 that takes two arguments (the path of the master file and the name | |
791 of the included file) and returns a valid path or nil -- if the | |
792 subfile can't be found. | |
793 | |
794 :match-number INTEGER (default: 1) ... The number of the match/group | |
795 in the pattern holding the subfile's name. 0 refers the whole | |
796 match, 1 to the first group. | |
797 | |
798 :stubp FUNCTION ... if (FUNCTION MASTER INCLUDED-FILE) returns non-nil, | |
799 INCLUDED-FILE is a stub -- see below. | |
800 | |
801 :stub-flag ... files of this type are stubs -- see below. | |
802 | |
803 :scan-depth INTEGER (default: 0) ... Whether included files should be | |
804 rescanned. Set this to 0 to disable re-scanning of included file. | |
805 | |
806 :preprocess FUNCTION ... A function modifying a buffer holding the | |
807 master file so that pattern matching becomes easier. This is usually | |
808 used to narrow a buffer to the relevant region. This function could also | |
809 be destructive and simply delete non-relevant text. | |
810 | |
811 :case-sensitive BOOLEAN (default: nil) ... Whether a pattern is | |
812 case-sensitive or not. | |
813 | |
814 | |
815 Stubs: | |
816 | |
817 First, a stub is a file that shows up in the menu but will not be | |
818 included in an ingroup's file listing -- i.e. filesets will never | |
819 operate on this file automatically. Secondly, in opposition to normal | |
820 files stubs are not scanned for new inclusion groups. This is useful if | |
821 you want to have quick access to library headers. | |
822 | |
823 In the menu, an asterisk is appended to the stub's name. | |
824 | |
825 | |
826 Remove Duplicates: | |
827 | |
828 E.g. File A and file B refer to file X; X refers to A. If | |
829 you choose not to remove duplicates the tree would look like: | |
830 | |
831 M + A - X - A ... | |
832 B - X - A ... | |
833 | |
834 As you can see, there is some chance that you run in circles. | |
835 Nevertheless, up to some degree this could still be what you want. | |
836 | |
837 With duplicates removed, it would be: | |
838 | |
839 M + A - X | |
840 B" | |
841 :set (function filesets-set-default) | |
842 :type '(repeat | |
843 :tag "Include" | |
844 (list | |
845 :tag "Definition" :value ("^.+\\.suffix$" t) | |
846 (regexp :tag "File Pattern" :value "^.+\\.suffix$") | |
847 (boolean :tag "Remove Duplicates" :value t) | |
848 (repeat :tag "Commands" | |
849 (repeat :tag "Command" | |
850 (choice | |
851 :tag "Definition" | |
852 (list :tag ":name" | |
853 :value (:name "") | |
854 (const :format "" :value :name) | |
855 (string :tag "String")) | |
856 (list :tag ":pattern" | |
857 :value (:pattern "\\<CMD\\W*\\(.+\\)\\>") | |
858 (const :format "" :value :pattern) | |
859 (regexp :tag "RegExp")) | |
860 (list :tag ":get-file-name" | |
861 :value (:get-file-name) | |
862 (const :format "" :value :get-file-name) | |
863 (function :tag "Function")) | |
864 (list :tag ":match-number" | |
865 :value (:match-number 1) | |
866 (const :format "" :value :match-number) | |
867 (integer :tag "Integer")) | |
868 (list :tag ":stub-flag" | |
869 :value (:stub-flag t) | |
870 (const :format "" :value :stub-flag) | |
871 (boolean :tag "Boolean")) | |
872 (list :tag ":stubp" | |
873 :value (:stubp) | |
874 (const :format "" :value :stubp) | |
875 (function :tag "Function")) | |
876 (list :tag ":scan-depth" | |
877 :value (:scan-depth 0) | |
878 (const :format "" :value :scan-depth) | |
879 (integer :tag "Integer")) | |
880 (list :tag ":case-sensitive" | |
881 :value (:case-sensitive) | |
882 (const :format "" :value :case-sensitive) | |
883 (boolean :tag "Boolean")) | |
884 (list :tag ":preprocess" | |
885 :value (:preprocess) | |
886 (const :format "" :value :preprocess) | |
887 (function :tag "Function"))))))) | |
888 :group 'filesets) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
889 (put 'filesets-ingroup-patterns 'risky-local-variable t) |
44934 | 890 |
891 (defcustom filesets-data | |
892 nil | |
893 "*Fileset definitions. | |
894 | |
895 A fileset is either a list of files, a file pattern, a base directory | |
896 and a search pattern (for files), or a base file. Changes to this | |
897 variable will take effect after rebuilding the menu. | |
898 | |
899 Caveat: Fileset names have to be unique. | |
900 | |
901 Example definition: | |
902 '\(\(\"My Wiki\" | |
903 \(:ingroup \"~/Etc/My-Wiki/WikiContents\")) | |
904 \(\"My Homepage\" | |
905 \(:pattern \"~/public_html/\" \"^.+\\\\.html$\") | |
906 \(:open filesets-find-file)) | |
907 \(\"User Configuration\" | |
908 \(:files \"~/.xinitrc\" | |
909 \"~/.bashrc\" | |
910 \"~/.bash_profile\")) | |
911 \(\"HOME\" | |
912 \(:tree \"~\" \"^[^.].*[^~]$\") | |
913 \(:filter-dirs-flag t))) | |
914 | |
915 `filesets-data' is a list of (NAME-AS-STRING . DEFINITION), DEFINITION | |
916 being an association list with the fields: | |
917 | |
918 :files FILE-1 .. FILE-N ... a list of files belonging to a fileset | |
919 | |
920 :ingroup FILE-NAME ... an inclusion group's base file. | |
921 | |
922 :tree ROOT-DIR PATTERN ... a base directory and a file pattern | |
923 | |
924 :pattern DIR PATTERN ... PATTERN is a regular expression comprising path | |
925 and file pattern -- e.g. 'PATH/^REGEXP$'. Note the `^' at the beginning | |
926 of the file name pattern. | |
927 | |
928 :filter-dirs-flag BOOLEAN ... is only used in conjunction with :tree. | |
929 | |
930 :tree-max-level INTEGER ... recurse into directories this many levels | |
44959 | 931 \(see `filesets-tree-max-level' for a full explanation) |
44934 | 932 |
933 :dormant-flag BOOLEAN ... non-nil means don't show this item in the | |
934 menu; dormant filesets can still be manipulated via commands available | |
935 from the minibuffer -- e.g. `filesets-open', `filesets-close', or | |
936 `filesets-run-cmd' | |
937 | |
938 :dormant-p FUNCTION ... a function returning :dormant-flag | |
939 | |
940 :open FUNCTION ... the function used to open file belonging to this | |
941 fileset. The function takes a file name as argument | |
942 | |
943 :save FUNCTION ... the function used to save file belonging to this | |
944 fileset; it takes no arguments, but works on the current buffer. | |
945 | |
946 Either :files, :pattern, :tree, or :ingroup must be supplied. :files | |
947 overrules :tree, :tree overrules :pattern, :pattern overrules :ingroup, | |
948 i.e. these tags are mutually exclusive. The fields :open and :save are | |
949 optional. | |
950 | |
951 In conjunction with the :tree tag, :save is void. :open refers to the | |
952 function used for opening files in a directory, not for opening the | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
953 directory. For browsing directories, `filesets-browse-dir-function' is used. |
44934 | 954 |
955 Before using :ingroup, make sure that the file type is already | |
956 defined in `filesets-ingroup-patterns'." | |
957 :group 'filesets | |
958 :set (function filesets-data-set-default) | |
959 :type '(repeat | |
960 (cons :tag "Fileset" | |
961 (string :tag "Name" :value "") | |
962 (repeat :tag "Data" | |
963 (choice | |
964 :tag "Type" :value nil | |
965 (list :tag "Pattern" | |
966 :value (:pattern "~/" "^.+\\.suffix$") | |
967 (const :format "" :value :pattern) | |
968 (directory :tag "Dir") | |
969 (regexp :tag "Pattern")) | |
970 (cons :tag "Files" | |
971 :value (:files) | |
972 (const :format "" :value :files) | |
973 (repeat :tag "Files" file)) | |
974 (list :tag "Single File" | |
975 :value (:file "~/") | |
976 (const :format "" :value :file) | |
977 (file :tag "File")) | |
978 (list :tag "Inclusion group" | |
979 :value (:ingroup "~/") | |
980 (const :format "" :value :ingroup) | |
981 (file :tag "File" :value "~/")) | |
982 (list :tag "Directory Tree" | |
983 :value (:tree "~/" "^.+\\.suffix$") | |
984 (const :format "" :value :tree) | |
985 (directory :tag "Dir") | |
986 (regexp :tag "Pattern")) | |
987 (list :tag "Filter directories" | |
988 :value (:filter-dirs-flag) | |
989 (const :format "" :value :filter-dirs-flag) | |
990 (boolean :tag "Boolean" :value nil)) | |
991 (list :tag "Scanning depth" | |
992 :value (:tree-max-level 3) | |
993 (const :format "" :value :tree-max-level) | |
994 (integer :tag "Integer")) | |
995 (list :tag "Verbosity" | |
996 :value (:verbosity 1) | |
997 (const :format "" :value :verbosity) | |
998 (integer :tag "Integer")) | |
999 (list :tag "Conceal fileset (Flag)" | |
1000 :value (:dormant-flag) | |
1001 (const :format "" :value :dormant-flag) | |
1002 (boolean :tag "Boolean")) | |
1003 (list :tag "Conceal fileset (Function)" | |
1004 :value (:dormant-p) | |
1005 (const :format "" :value :dormant-p) | |
1006 (function :tag "Function")) | |
1007 (list :tag "Save function" | |
1008 :value (:save) | |
1009 (const :format "" :value :save) | |
1010 (function :tag "Function")) | |
1011 (list :tag "Open function" | |
1012 :value (:open) | |
1013 (const :format "" :value :open) | |
1014 (function :tag "Function"))))))) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1015 (put 'filesets-data 'risky-local-variable t) |
44934 | 1016 |
1017 | |
1018 (defcustom filesets-query-user-limit 15 | |
1019 "*Query the user before opening a fileset with that many files." | |
1020 :set (function filesets-set-default) | |
1021 :type 'integer | |
1022 :group 'filesets) | |
1023 | |
1024 | |
1025 ;;; Emacs compatibility | |
1026 (eval-and-compile | |
1027 (if filesets-running-xemacs | |
1028 (progn | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1029 (fset 'filesets-error 'error) |
44934 | 1030 (fset 'filesets-add-submenu 'add-submenu)) |
1031 | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1032 (require 'easymenu) |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1033 |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1034 (defun filesets-error (class &rest args) |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1035 "`error' wrapper." |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1036 (error (mapconcat 'identity args " "))) |
44934 | 1037 |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1038 ;; This should work for 21.1 Emacs |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1039 (defun filesets-add-submenu (menu-path submenu &optional |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1040 before in-menu) |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1041 "`easy-menu-define' wrapper." |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1042 (easy-menu-define |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1043 filesets-submenu global-map "Filesets menu" submenu)) |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1044 )) |
44934 | 1045 |
1046 (defun filesets-filter-dir-names (lst &optional negative) | |
1047 "Remove non-directory names from a list of strings. If NEGATIVE is | |
1048 non-nil, remove all directory names." | |
1049 (filesets-filter-list lst | |
1050 (lambda (x) | |
1051 (and (not (string-match "^\\.+/$" x)) | |
1052 (if negative | |
1053 (not (string-match "[:/\\]$" x)) | |
1054 (string-match "[:/\\]$" x)))))) | |
1055 | |
1056 (defun filesets-conditional-sort (lst &optional access-fn simply-do-it) | |
1057 "Return a sorted copy of LST, LST being a list of strings. | |
1058 If `filesets-sort-menu-flag' is nil, return LST itself. | |
1059 | |
1060 ACCESS-FN ... function to get the string value of LST's elements. | |
1061 | |
1062 If SIMPLY-DO-IT is non-nil, the list is sorted regardless of | |
1063 `filesets-sort-menu-flag'." | |
1064 (if filesets-sort-menu-flag | |
1065 (let* ((fni (or access-fn | |
1066 (function identity))) | |
1067 (fn (if filesets-sort-case-sensitive-flag | |
1068 (lambda (a b) | |
1069 (string< (funcall fni a) | |
1070 (funcall fni b))) | |
1071 (lambda (a b) | |
1072 (string< (upcase (funcall fni a)) | |
1073 (upcase (funcall fni b))))))) | |
1074 (sort (copy-list lst) fn)) | |
1075 lst)) | |
1076 | |
1077 (defun filesets-directory-files (dir &optional | |
1078 pattern what full-flag match-dirs-flag) | |
1079 "Get WHAT (:files or :dirs) in DIR. If PATTERN is provided return only | |
1080 those entries matching this regular expression. If MATCH-DIRS-FLAG is | |
1081 non-nil, also match directory entries. Return full path if FULL-FLAG is | |
1082 non-nil." | |
1083 (filesets-message 2 "Filesets: scanning %S" dir) | |
1084 (cond | |
1085 ((file-exists-p dir) | |
1086 (let ((files nil) | |
1087 (dirs nil)) | |
1088 (dolist (this (file-name-all-completions "" dir)) | |
1089 (cond | |
1090 ((string-match "^\\.+/$" this) | |
1091 nil) | |
1092 ((string-match "[:/\\]$" this) | |
1093 (when (or (not match-dirs-flag) | |
1094 (not pattern) | |
1095 (string-match pattern this)) | |
1096 (filesets-message 5 "Filesets: matched dir %S with pattern %S" | |
1097 this pattern) | |
1098 (setq dirs (cons this dirs)))) | |
1099 (t | |
1100 (when (or (not pattern) | |
1101 (string-match pattern this)) | |
1102 (filesets-message 5 "Filesets: matched file %S with pattern %S" | |
1103 this pattern) | |
1104 (setq files (cons (if full-flag | |
1105 (concat (file-name-as-directory dir) this) | |
1106 this) | |
1107 files)))))) | |
1108 (cond | |
1109 ((equal what ':dirs) | |
1110 (filesets-conditional-sort dirs)) | |
1111 ((equal what ':files) | |
1112 (filesets-conditional-sort files)) | |
1113 (t | |
1114 (append (filesets-conditional-sort files) | |
1115 (filesets-conditional-sort dirs)))))) | |
1116 (filesets-be-docile-flag | |
1117 (filesets-message 1 "Filesets: %S doesn't exist" dir) | |
1118 nil) | |
1119 (t | |
1120 (filesets-error 'error "Filesets: " dir " does not exist")))) | |
1121 | |
1122 (defun filesets-quote (txt) | |
1123 "Return TXT in quotes." | |
1124 (concat "\"" txt "\"")) | |
1125 | |
1126 (defun filesets-get-selection () | |
1127 "Get the text between mark and point -- i.e. the selection or region." | |
1128 (let ((m (mark)) | |
1129 (p (point))) | |
1130 (if m | |
1131 (buffer-substring (min m p) (max m p)) | |
1132 (filesets-error 'error "No selection.")))) | |
1133 | |
1134 (defun filesets-get-quoted-selection () | |
1135 "Return the currently selected text in quotes." | |
1136 (filesets-quote (filesets-get-selection))) | |
1137 | |
1138 (defun filesets-get-shortcut (n) | |
1139 "Create menu shortcuts based on number N." | |
1140 (let ((n (mod (- n 1) 51))) | |
1141 (cond | |
1142 ((not filesets-menu-shortcuts-flag) | |
1143 "") | |
1144 ((<= n 9) | |
1145 (concat (number-to-string n) " ")) | |
1146 ((<= n 35) | |
1147 (format "%c " (+ 87 n))) | |
1148 ((<= n 51) | |
1149 (format "%c " (+ -3 n)))))) | |
1150 | |
1151 (defun filesets-files-equalp (a b) | |
1152 "Compare two filenames A and B after expansion." | |
1153 (equal (expand-file-name a) (expand-file-name b))) | |
1154 | |
1155 (defun filesets-files-in-same-directory-p (a b) | |
1156 "Compare two filenames A and B after expansion." | |
1157 (let ((ad (file-name-directory (expand-file-name a))) | |
1158 (bd (file-name-directory (expand-file-name b)))) | |
1159 (equal ad bd))) | |
1160 | |
1161 (defun filesets-convert-path-list (string) | |
1162 "Return a path-list given as STRING as list." | |
1163 (if string | |
1164 (mapcar (lambda (x) (file-name-as-directory x)) | |
1165 (split-string string path-separator)) | |
1166 nil)) | |
1167 | |
1168 (defun filesets-which-file (master filename &optional path-list) | |
1169 "Search for a FILENAME relative to a MASTER file in PATH-LIST." | |
1170 (let ((f (concat (file-name-directory master) | |
1171 filename))) | |
1172 (if (file-exists-p f) | |
1173 f | |
1174 (some (lambda (dir) | |
1175 (let ((dir (file-name-as-directory dir)) | |
1176 (files (if (file-exists-p dir) | |
1177 (filesets-directory-files dir nil ':files) | |
1178 nil))) | |
1179 (some (lambda (file) | |
1180 (if (equal filename (file-name-nondirectory file)) | |
1181 (concat dir file) | |
1182 nil)) | |
1183 files))) | |
1184 path-list)))) | |
1185 | |
1186 | |
1187 (defun filesets-eviewer-get-props (entry) | |
1188 "Get ENTRY's (representing an external viewer) properties." | |
1189 (nth 2 entry)) | |
1190 | |
1191 (defun filesets-eviewer-constraint-p (entry) | |
1192 (let* ((props (filesets-eviewer-get-props entry)) | |
1193 (constraint (assoc ':constraintp props)) | |
1194 (constraint-flag (assoc ':constraint-flag props))) | |
1195 (cond | |
1196 (constraint | |
1197 (funcall (cadr constraint))) | |
1198 (constraint-flag | |
1199 (eval (cadr constraint-flag))) | |
1200 (t | |
1201 t)))) | |
1202 | |
1203 (defun filesets-get-external-viewer (file) | |
1204 "Find an external viewer for FILE." | |
1205 (let ((filename (file-name-nondirectory file))) | |
1206 (some | |
1207 (lambda (entry) | |
1208 (when (and (string-match (nth 0 entry) filename) | |
1209 (filesets-eviewer-constraint-p entry)) | |
1210 entry)) | |
1211 filesets-external-viewers))) | |
1212 | |
1213 (defun filesets-get-external-viewer-by-name (name) | |
1214 "Get the external viewer definition called NAME." | |
1215 (when name | |
1216 (some | |
1217 (lambda (entry) | |
1218 (when (and (string-equal (nth 1 entry) name) | |
1219 (filesets-eviewer-constraint-p entry)) | |
1220 entry)) | |
1221 filesets-external-viewers))) | |
1222 | |
1223 (defun filesets-filetype-property (filename event &optional entry) | |
1224 "Returns non-nil if a file of a specific type has special flags/tags. | |
1225 | |
1226 Events (corresponding tag): | |
1227 | |
1228 on-open-all (:ignore-on-open-all) ... Exclude files of this when opening | |
1229 a fileset | |
1230 | |
1231 on-grep (:ignore-on-read-text) ... Exclude files of this when running | |
1232 the \"Grep <<selection>>\" command | |
1233 | |
1234 on-capture-output (:capture-output) ... Capture output of an external viewer | |
1235 | |
1236 on-ls ... not used | |
1237 | |
1238 on-cmd ... not used | |
1239 | |
1240 on-close-all ... not used" | |
1241 (let ((def (filesets-eviewer-get-props | |
1242 (or entry | |
1243 (filesets-get-external-viewer filename))))) | |
1244 (filesets-alist-get def | |
1245 (case event | |
1246 ((on-open-all) ':ignore-on-open-all) | |
1247 ((on-grep) ':ignore-on-read-text) | |
1248 ((on-cmd) nil) | |
1249 ((on-close-all) nil)) | |
1250 nil t))) | |
1251 | |
1252 (defun filesets-filetype-get-prop (property filename &optional entry) | |
1253 "Returns PROPERTY for filename -- use ENTRY if provided." | |
1254 (let ((def (filesets-eviewer-get-props | |
1255 (or entry | |
1256 (filesets-get-external-viewer filename))))) | |
1257 (when def | |
1258 (filesets-alist-get def property nil t)))) | |
1259 | |
1260 (defun filesets-reset-filename-on-change () | |
1261 "Reset a buffer's filename if the buffer is being modified." | |
1262 (when filesets-output-buffer-flag | |
1263 (set-visited-file-name nil t))) | |
1264 | |
1265 (defun filesets-spawn-external-viewer (file &optional ev-entry) | |
1266 "Start an external viewer for FILE. | |
1267 Use the viewer defined in EV-ENTRY (a valid element of | |
1268 `filesets-external-viewers') if provided." | |
1269 (let* ((file (expand-file-name file)) | |
1270 (entry (or ev-entry | |
1271 (filesets-get-external-viewer file)))) | |
1272 (if entry | |
1273 (let* ((vwr (cadr entry)) | |
1274 (co-flag (filesets-filetype-get-prop ':capture-output file entry)) | |
1275 (oh (filesets-filetype-get-prop ':open-hook file entry)) | |
1276 (args (let ((fmt (filesets-filetype-get-prop ':args file entry))) | |
1277 (if fmt | |
1278 (let ((rv "")) | |
1279 (dolist (this fmt rv) | |
1280 (setq rv (concat rv | |
1281 (cond | |
1282 ((stringp this) | |
1283 (format this file)) | |
1284 ((and (symbolp this) | |
1285 (fboundp this)) | |
1286 (format "%S" (funcall this))) | |
1287 (t | |
1288 (format "%S" this))))))) | |
1289 (format "%S" file)))) | |
1290 (output | |
1291 (cond | |
1292 ((and (functionp vwr) co-flag) | |
1293 (funcall vwr file)) | |
1294 ((functionp vwr) | |
1295 (funcall vwr file) | |
1296 nil) | |
1297 (co-flag | |
1298 (shell-command-to-string (format "%s %s" vwr args))) | |
1299 (t | |
1300 (shell-command (format "%s %s&" vwr args)) | |
1301 nil)))) | |
1302 (if co-flag | |
1303 (progn | |
1304 (switch-to-buffer (format "Filesets: %s %s" vwr file)) | |
1305 (insert output) | |
1306 (make-local-variable 'filesets-output-buffer-flag) | |
1307 (setq filesets-output-buffer-flag t) | |
1308 (set-visited-file-name file t) | |
1309 (when oh | |
1310 (run-hooks 'oh)) | |
1311 (set-buffer-modified-p nil) | |
1312 (setq buffer-read-only t) | |
1313 (beginning-of-buffer)) | |
1314 (when oh | |
1315 (run-hooks 'oh)))) | |
1316 (filesets-error 'error | |
1317 "Filesets: general error when spawning external viewer")))) | |
1318 | |
1319 (defun filesets-find-file (file) | |
1320 "Call `find-file' after a possible delay (see `filesets-find-file-delay'). | |
1321 If `filesets-be-docile-flag' is true, a file, which isn't readable, will | |
1322 not be opened." | |
1323 ; (sleep-for filesets-find-file-delay) | |
1324 (when (or (file-readable-p file) | |
1325 (not filesets-be-docile-flag)) | |
1326 (sit-for filesets-find-file-delay) | |
1327 (find-file file))) | |
1328 | |
1329 (defun filesets-find-or-display-file (&optional file viewer) | |
1330 "Visit FILE using an external viewer or open it in an Emacs buffer." | |
1331 (interactive) | |
1332 (let* ((file (or file | |
1333 (read-file-name "Find file: " nil nil viewer))) | |
1334 (external-viewer-def (or | |
1335 (filesets-get-external-viewer-by-name viewer) | |
1336 (filesets-get-external-viewer file)))) | |
1337 (filesets-message 3 "Filesets: view %S using %s" file external-viewer-def) | |
1338 (if external-viewer-def | |
1339 (filesets-spawn-external-viewer file external-viewer-def) | |
1340 (filesets-find-file file)))) | |
1341 | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
1342 (defun filesets-find-file-using () |
44934 | 1343 "Select a viewer and call `filesets-find-or-display-file'." |
1344 (interactive) | |
1345 (let* ((lst (mapcar (lambda (this) | |
1346 (let ((a (cadr this))) | |
1347 (list (format "%s" a) a))) | |
1348 filesets-external-viewers)) | |
1349 (viewer (completing-read "Using viewer: " lst nil t))) | |
1350 (when viewer | |
1351 (filesets-find-or-display-file nil (cadr (assoc viewer lst)))))) | |
1352 | |
1353 (defun filesets-browser-name () | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1354 "Get the directory browser's name as defined in `filesets-browse-dir-function'." |
44934 | 1355 (cond |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1356 ((listp filesets-browse-dir-function) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1357 (car filesets-browse-dir-function)) |
44934 | 1358 (t |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1359 filesets-browse-dir-function))) |
44934 | 1360 |
1361 (defun filesets-browse-dir (dir) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1362 "Browse DIR using `filesets-browse-dir-function'." |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1363 (if (functionp filesets-browse-dir-function) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1364 (funcall filesets-browse-dir-function dir) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1365 (let ((name (car filesets-browse-dir-function)) |
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1366 (args (format (cadr filesets-browse-dir-function) (expand-file-name dir)))) |
44934 | 1367 (with-temp-buffer |
1368 (start-process (concat "Filesets:" name) | |
1369 "*Filesets external directory browser*" | |
1370 name args))))) | |
1371 | |
1372 (defun filesets-get-fileset-name (something) | |
1373 "Get SOMETHING's name. (Don't ask.)" | |
1374 (cond | |
1375 ((listp something) | |
1376 (car something)) | |
1377 (t | |
1378 something))) | |
1379 | |
1380 (defun filesets-data-get-name (entry) | |
1381 "Access to `filesets-data'. Get the entry's name" | |
1382 (car entry)) | |
1383 | |
1384 (defun filesets-data-get-data (entry) | |
1385 "Access to `filesets-data'. Get the entry's data section" | |
1386 (cdr entry)) | |
1387 | |
1388 (defun filesets-alist-get (alist key &optional default carp) | |
1389 "Get KEY's value in the association list ALIST. | |
1390 Return DEFAULT if not found. Return (car VALUE) if CARP is non-nil." | |
1391 (let* ((elt (assoc key alist))) | |
1392 (cond | |
1393 (elt | |
1394 (if carp | |
1395 (cadr elt) | |
1396 (cdr elt))) | |
1397 (default default) | |
1398 (t nil)))) | |
1399 | |
1400 (defun filesets-data-get (entry key &optional default carp) | |
1401 "Extract the value for KEY in the data part of fileset ENTRY. | |
1402 Return DEFAULT if not found. Return (car VALUE) if CARP is non-nil." | |
1403 (filesets-alist-get (filesets-data-get-data entry) key default carp)) | |
1404 | |
1405 (defun filesets-data-set (entry key value) | |
1406 "Set the value for KEY in the data part of fileset ENTRY." | |
1407 (let* ((alist (filesets-data-get-data entry)) | |
1408 (elt (assoc key alist))) | |
1409 (if elt | |
1410 (setcdr elt value) | |
1411 (setcdr entry (cons (cons key value) alist))))) | |
1412 | |
1413 (defun filesets-entry-mode (entry) | |
1414 "Return fileset ENTRY's mode: :files, :file, :tree, :pattern, or :ingroup. | |
1415 See `filesets-data'." | |
1416 (let ((data (filesets-data-get-data entry))) | |
1417 (some (lambda (x) | |
1418 (if (assoc x data) | |
1419 x)) | |
1420 '(:files :tree :pattern :ingroup :file)))) | |
1421 | |
1422 (defun filesets-entry-get-open-fn (fileset-name &optional fileset-entry) | |
1423 "Get the open-function for FILESET-NAME. | |
1424 Use FILESET-ENTRY for finding the open function, if provided." | |
1425 (filesets-data-get (or fileset-entry | |
1426 (filesets-get-fileset-from-name fileset-name)) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1427 ':open filesets-open-file-function t)) |
44934 | 1428 |
1429 (defun filesets-entry-get-save-fn (fileset-name &optional fileset-entry) | |
1430 "Get the save-function for FILESET-NAME. | |
1431 Use FILESET-ENTRY for finding the save function, if provided." | |
1432 (filesets-data-get (or fileset-entry | |
1433 (filesets-get-fileset-from-name fileset-name)) | |
45132
c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
Richard M. Stallman <rms@gnu.org>
parents:
45130
diff
changeset
|
1434 ':save filesets-save-buffer-function t)) |
44934 | 1435 |
1436 (defun filesets-entry-get-files (entry) | |
1437 "Get the file list for fileset ENTRY." | |
1438 (filesets-data-get entry ':files)) | |
1439 | |
1440 (defun filesets-entry-set-files (entry data &optional anyways) | |
1441 "Set the file list for fileset ENTRY." | |
1442 (let ((files (filesets-entry-get-files entry))) | |
1443 (if (or anyways files) | |
1444 (filesets-data-set entry ':files data)))) | |
1445 | |
1446 (defun filesets-entry-get-verbosity (entry) | |
1447 "Get verbosity level for fileset ENTRY." | |
1448 (filesets-data-get entry ':verbosity 1 t)) | |
1449 | |
1450 (defun filesets-entry-get-file (entry) | |
1451 "Get the single file for fileset ENTRY." | |
1452 (filesets-data-get entry ':file nil t)) | |
1453 | |
1454 (defun filesets-entry-get-pattern (entry) | |
1455 "Get the base directory + file pattern for fileset ENTRY." | |
1456 ; (filesets-data-get entry ':pattern nil t)) | |
1457 (filesets-data-get entry ':pattern)) | |
1458 | |
1459 (defun filesets-entry-get-pattern--pattern (list) | |
1460 "Get the file pattern for LIST." | |
1461 (if (= (length list) 1) ;; for compatibility with filesets < v1.5.5 | |
1462 (file-name-nondirectory (car list)) | |
1463 (cadr list))) | |
1464 | |
1465 (defun filesets-entry-get-pattern--dir (list) | |
1466 "Get a file pattern's base directory for LIST." | |
1467 (if (= (length list) 1) ;; for compatibility with filesets < v1.5.5 | |
1468 (file-name-directory (car list)) | |
1469 (car list))) | |
1470 | |
1471 (defun filesets-entry-get-tree (entry) | |
1472 "Get the tree pattern for fileset ENTRY." | |
1473 (filesets-data-get entry ':tree)) | |
1474 | |
1475 (defun filesets-entry-get-dormant-flag (entry) | |
1476 "Get dormant flag for fileset ENTRY." | |
1477 (let ((fn (filesets-data-get entry ':dormant-p nil t))) | |
1478 (if fn | |
1479 (funcall fn) | |
1480 (filesets-data-get entry ':dormant-flag nil t)))) | |
1481 | |
1482 (defun filesets-entry-get-filter-dirs-flag (entry) | |
1483 "Get filter-dirs-flag for fileset ENTRY." | |
1484 (filesets-data-get entry ':filter-dirs-flag nil t)) | |
1485 | |
1486 (defun filesets-entry-get-tree-max-level (entry) | |
1487 "Get maximal tree scanning depth for fileset ENTRY." | |
1488 (filesets-data-get entry ':tree-max-level nil t)) | |
1489 | |
1490 (defun filesets-entry-get-master (entry) | |
1491 "Get the base file for fileset ENTRY." | |
1492 (filesets-data-get entry ':ingroup nil t)) | |
1493 | |
1494 (defun filesets-file-open (open-function file-name &optional fileset-name) | |
1495 "Open FILE-NAME using OPEN-FUNCTION. If OPEN-FUNCTION is nil, it's | |
1496 value will be deduced from FILESET-NAME" | |
1497 (let ((open-function (or open-function | |
1498 (filesets-entry-get-open-fn fileset-name)))) | |
1499 (if (file-readable-p file-name) | |
1500 (funcall open-function file-name) | |
1501 (message "Filesets: Couldn't open `%s'" file-name)))) | |
1502 | |
1503 (defun filesets-file-close (save-function buffer) | |
1504 "Close BUFFER. | |
1505 First, save the buffer's contents using SAVE-FUNCTION. Then, kill buffer | |
1506 if `buffer-modified-p' returns nil. | |
1507 | |
1508 SAVE-FUNCTION takes no argument, but works on the current buffer." | |
1509 (save-excursion | |
1510 (set-buffer buffer) | |
1511 (if (buffer-modified-p) | |
1512 (funcall save-function)) | |
1513 (if (not (buffer-modified-p)) | |
1514 (kill-buffer buffer)))) | |
1515 | |
1516 (defun filesets-get-fileset-from-name (name &optional mode) | |
1517 "Get fileset definition for NAME." | |
1518 (case mode | |
1519 ((:ingroup :tree) | |
1520 name) | |
1521 (t | |
1522 (assoc name filesets-data)))) | |
1523 | |
1524 | |
1525 ;;; commands | |
1526 (defun filesets-cmd-get-def (cmd-name) | |
1527 "Get `filesets-commands' entry for CMD-NAME." | |
1528 (assoc cmd-name filesets-commands)) | |
1529 | |
1530 (defun filesets-cmd-get-args (cmd-name) | |
1531 (let ((args (let ((def (filesets-cmd-get-def cmd-name))) | |
1532 (nth 2 def))) | |
1533 (rv nil)) | |
1534 (dolist (this args rv) | |
1535 (cond | |
1536 ((and (symbolp this) (fboundp this)) | |
1537 (let ((x (funcall this))) | |
1538 (setq rv (append rv (if (listp x) x (list x)))))) | |
1539 (t | |
1540 (setq rv (append rv (list this)))))))) | |
1541 | |
1542 (defun filesets-cmd-get-fn (cmd-name) | |
1543 (let ((def (filesets-cmd-get-def cmd-name))) | |
1544 (nth 1 def))) | |
1545 | |
1546 (defun filesets-cmd-show-result (cmd output) | |
1547 "Show OUTPUT of CMD (a shell command)." | |
1548 (pop-to-buffer "*Filesets: Shell Command Output*") | |
1549 (end-of-buffer) | |
1550 (insert "*** ") | |
1551 (insert cmd) | |
1552 (newline) | |
1553 (insert output) | |
1554 (newline)) | |
1555 | |
1556 (defun filesets-run-cmd--repl-fn (arg &optional format-fn) | |
1557 "Helper function for `filesets-run-cmd'. Apply FORMAT-FN to arg. | |
1558 Replace <file-name> or <<file-name>> with filename." | |
1559 (funcall format-fn (cond | |
1560 ((equal arg "<file-name>") | |
1561 (buffer-file-name)) | |
1562 ((equal arg "<<file-name>>") | |
1563 (filesets-quote (buffer-file-name))) | |
1564 (t | |
1565 arg)))) | |
1566 | |
1567 (defun filesets-run-cmd (&optional cmd-name fileset mode) | |
1568 "Run CMD-NAME (see `filesets-commands') on FILESET." | |
1569 (interactive) | |
1570 (let* ((cmd-name (or cmd-name | |
1571 (completing-read "Select command: " filesets-commands | |
1572 nil t))) | |
1573 (name (or fileset | |
1574 (completing-read "Select fileset: " filesets-data nil t)))) | |
1575 (when (and cmd-name name) | |
1576 (let* ((event (if (equal cmd-name "Grep <<selection>>") | |
1577 'on-grep | |
1578 'on-cmd)) | |
1579 (files (if (and fileset | |
1580 (or (equal mode ':ingroup) | |
1581 (equal mode ':tree))) | |
1582 (filesets-get-filelist fileset mode event) | |
1583 (filesets-get-filelist | |
1584 (filesets-get-fileset-from-name name) | |
1585 mode event)))) | |
1586 (when files | |
1587 (let ((fn (filesets-cmd-get-fn cmd-name)) | |
1588 (args (filesets-cmd-get-args cmd-name))) | |
1589 (dolist (this files nil) | |
1590 (save-excursion | |
1591 (save-restriction | |
1592 (let ((buffer (filesets-find-file this))) | |
1593 (when buffer | |
1594 (beginning-of-buffer) | |
1595 (let () | |
1596 (cond | |
1597 ((stringp fn) | |
1598 (let* ((args | |
1599 (let ((txt "")) | |
1600 (dolist (this args txt) | |
1601 (setq txt | |
1602 (concat txt | |
1603 (filesets-run-cmd--repl-fn | |
1604 this | |
1605 (lambda (this) | |
1606 (if (equal txt "") "" " ") | |
1607 (format "%s" this)))))))) | |
1608 (cmd (concat fn " " args))) | |
1609 (filesets-cmd-show-result | |
1610 cmd (shell-command-to-string cmd)))) | |
1611 ((symbolp fn) | |
1612 (let ((args | |
1613 (let ((argl nil)) | |
1614 (dolist (this args argl) | |
1615 (setq argl | |
1616 (append argl | |
1617 (filesets-run-cmd--repl-fn | |
1618 this | |
1619 'list))))))) | |
1620 (apply fn args)))))))))))))))) | |
1621 | |
1622 (defun filesets-get-cmd-menu () | |
1623 "Create filesets command menu." | |
1624 `("+ Commands" | |
1625 . ,(mapcar (lambda (this) | |
1626 (let ((name (car this))) | |
1627 `[,name (filesets-run-cmd ,name)])) | |
1628 filesets-commands))) | |
1629 | |
1630 | |
1631 ;;; sampe commands | |
1632 (defun filesets-cmd-query-replace-getargs () | |
1633 "Get arguments for `filesets-cmd-query-replace'." | |
1634 (let* ((from-string (read-string "Filesets query replace: " | |
1635 "" | |
1636 'query-replace-history)) | |
1637 (to-string (read-string | |
1638 (format "Filesets query replace %s with: " from-string) | |
1639 "" | |
1640 'query-replace-history)) | |
1641 (delimited (y-or-n-p | |
1642 "Filesets query replace: respect word boundaries? "))) | |
1643 (list from-string to-string delimited))) | |
1644 | |
1645 (defun filesets-cmd-shell-command-getargs () | |
1646 "Get arguments for `filesets-cmd-shell-command'." | |
1647 (let* ((arg (read-string "Shell command (%s = file): " | |
1648 "%s" | |
1649 'shell-command-history))) | |
1650 arg)) | |
1651 | |
1652 (defun filesets-cmd-shell-command (txt) | |
1653 "Wrapper function for `shell-command'." | |
1654 (let ((ok (if (buffer-modified-p) | |
1655 (let ((ok (y-or-n-p "Save buffer? "))) | |
1656 (when ok | |
1657 (save-buffer)) | |
1658 ok) | |
1659 t))) | |
1660 (when ok | |
1661 (let ((cmd (format txt (buffer-file-name)))) | |
1662 (message "Filesets: %s" cmd) | |
1663 (filesets-cmd-show-result cmd | |
1664 (shell-command-to-string cmd)))))) | |
1665 | |
1666 | |
1667 ;;; body | |
1668 (defun filesets-get-filelist (entry &optional mode event) | |
1669 "Get all files for fileset ENTRY. | |
1670 Assume MODE (see `filesets-entry-mode'), if provided." | |
1671 (let* ((mode (or mode | |
1672 (filesets-entry-mode entry))) | |
1673 (fl (case mode | |
1674 ((:files) | |
1675 (filesets-entry-get-files entry)) | |
1676 ((:file) | |
1677 (list (filesets-entry-get-file entry))) | |
1678 ((:ingroup) | |
1679 (let ((entry (expand-file-name | |
1680 (if (stringp entry) | |
1681 entry | |
1682 (filesets-entry-get-master entry))))) | |
1683 (cons entry (filesets-ingroup-cache-get entry)))) | |
1684 ((:tree) | |
1685 (let ((dir (nth 0 entry)) | |
1686 (patt (nth 1 entry))) | |
1687 (filesets-directory-files dir patt ':files t))) | |
1688 ((:pattern) | |
1689 (let ((dirpatt (filesets-entry-get-pattern entry))) | |
1690 (if dirpatt | |
1691 (let ((dir (filesets-entry-get-pattern--dir dirpatt)) | |
1692 (patt (filesets-entry-get-pattern--pattern dirpatt))) | |
1693 ;;(filesets-message 3 "Filesets: scanning %s" dirpatt) | |
1694 (filesets-directory-files dir patt ':files t)) | |
1695 ;; (message "Filesets: malformed entry: %s" entry))))))) | |
1696 (filesets-error 'error "Filesets: malformed entry: " | |
1697 entry))))))) | |
1698 (filesets-filter-list fl | |
1699 (lambda (file) | |
1700 (not (filesets-filetype-property file event)))))) | |
1701 | |
1702 (defun filesets-open (&optional mode name lookup-name) | |
1703 "Open the fileset called NAME. | |
1704 Use LOOKUP-NAME for searching additional data if provided." | |
1705 (interactive) | |
1706 (let* ((name (or name | |
1707 (completing-read "Open fileset: " filesets-data nil t))) | |
1708 (fileset (filesets-get-fileset-from-name name mode)) | |
1709 (lookup-fs (if lookup-name | |
1710 (filesets-get-fileset-from-name lookup-name) | |
1711 fileset)) | |
1712 (mode (or mode (filesets-entry-mode lookup-fs)))) | |
1713 (if fileset | |
1714 (let* ((files (filesets-get-filelist fileset mode 'on-open-all)) | |
1715 (n (length files)) | |
1716 (open-function (filesets-entry-get-open-fn nil lookup-fs))) | |
1717 (if (or (<= n filesets-query-user-limit) | |
1718 (y-or-n-p (format "Filesets: Open all %d files in %s? " | |
1719 n name))) | |
1720 (dolist (this files nil) | |
1721 (filesets-file-open open-function this)) | |
1722 (message "Filesets: cancelled"))) | |
1723 (filesets-error 'error "Filesets: Unknown fileset: " name)))) | |
1724 | |
1725 (defun filesets-close (&optional mode name lookup-name) | |
1726 "Close all buffers belonging to the fileset called NAME. | |
1727 Use LOOKUP-NAME for deducing the save-function, if provided." | |
1728 (interactive) | |
1729 (let* ((name (or name | |
1730 (completing-read "Close fileset: " filesets-data nil t))) | |
1731 (fileset (filesets-get-fileset-from-name name mode)) | |
1732 (lookup-fs (if lookup-name | |
1733 (filesets-get-fileset-from-name lookup-name) | |
1734 fileset)) | |
1735 (mode (or mode (filesets-entry-mode lookup-fs)))) | |
1736 (if fileset | |
1737 (let ((files (filesets-get-filelist fileset mode 'on-close-all)) | |
1738 (save-function (filesets-entry-get-save-fn nil lookup-fs))) | |
1739 (dolist (file-name files nil) | |
1740 (let* ((buffer (get-file-buffer file-name))) | |
1741 (if buffer | |
1742 (filesets-file-close save-function buffer))))) | |
1743 ; (message "Filesets: Unknown fileset: `%s'" name)))) | |
1744 (filesets-error 'error "Filesets: Unknown fileset: " name)))) | |
1745 | |
1746 (defun filesets-add-buffer (&optional name buffer) | |
1747 "Add BUFFER (or current-buffer) to the fileset called NAME. | |
1748 User will be queried, if no fileset name is provided." | |
1749 (interactive) | |
1750 (let* ((buffer (or buffer | |
1751 (current-buffer))) | |
1752 (name (or name | |
1753 (completing-read | |
1754 (format "Add '%s' to fileset: " buffer) | |
1755 filesets-data nil t))) | |
1756 (entry (assoc name filesets-data))) | |
1757 (if entry | |
1758 (let* ((files (filesets-entry-get-files entry)) | |
1759 (this (buffer-file-name buffer)) | |
1760 (inlist (member* this files :test 'filesets-files-equalp))) | |
1761 (cond | |
1762 (inlist | |
1763 (message "Filesets: '%s' is already in '%s'" this name)) | |
1764 ((and (equal (filesets-entry-mode entry) ':files) | |
1765 this) | |
1766 (filesets-entry-set-files entry (cons this files) t) | |
1767 (filesets-set-config name 'filesets-data filesets-data)) | |
1768 (t | |
1769 (message "Filesets: Can't add '%s' to fileset '%s'" this name))))))) | |
1770 | |
1771 (defun filesets-remove-buffer (&optional name buffer) | |
1772 "Remove BUFFER (or current-buffer) to fileset NAME. | |
1773 User will be queried, if no fileset name is provided." | |
1774 (interactive) | |
1775 (let* ((buffer (or buffer | |
1776 (current-buffer))) | |
1777 (name (or name | |
1778 (completing-read | |
1779 (format "Remove '%s' from fileset: " buffer) | |
1780 filesets-data nil t))) | |
1781 (entry (assoc name filesets-data))) | |
1782 (if entry | |
1783 (let* ((files (filesets-entry-get-files entry)) | |
1784 (this (buffer-file-name buffer)) | |
1785 (inlist (member* this files :test 'filesets-files-equalp))) | |
1786 ;;(message "%s %s %s" files this inlist) | |
1787 (if (and files this inlist) | |
1788 (let ((new (list (cons ':files (delete (car inlist) files))))) | |
1789 (setcdr entry new) | |
1790 (filesets-set-config name 'filesets-data filesets-data)) | |
1791 (message "Filesets: Can't remove '%s' from fileset '%s'" | |
1792 this | |
1793 name)))))) | |
1794 | |
1795 (defun filesets-convert-patterns (name) | |
1796 "Change fileset NAME's mode from :pattern to :files." | |
1797 (interactive) | |
1798 (let ((entry (assoc name filesets-data))) | |
1799 (if entry | |
1800 (let ((pattern (filesets-entry-get-pattern entry)) | |
1801 (patfiles (filesets-get-filelist entry ':pattern))) | |
1802 (if pattern | |
1803 (progn | |
1804 (filesets-entry-set-files entry patfiles t) | |
1805 (filesets-set-config name 'filesets-data filesets-data))))))) | |
1806 | |
1807 (defun filesets-edit () | |
1808 "Customize `filesets-data'." | |
1809 (interactive) | |
1810 (customize-variable 'filesets-data)) | |
1811 | |
1812 (defun filesets-customize () | |
1813 "Customize the filesets group." | |
1814 (interactive) | |
1815 (customize-group 'filesets)) | |
1816 | |
1817 (defun filesets-info () | |
1818 "Display filesets's version information." | |
1819 (interactive) | |
1820 (if (y-or-n-p (format "Filesets v%s: visit homepage? " filesets-version)) | |
1821 (filesets-goto-homepage))) | |
1822 | |
1823 (defun filesets-goto-homepage () | |
1824 "Show filesets's homepage." | |
1825 (interactive) | |
1826 (browse-url filesets-homepage)) | |
1827 | |
1828 (defun filesets-remake-shortcut (count submenu) | |
1829 "Remake a submenus shortcut when wrapping long menus." | |
1830 (let* ((name (concat (filesets-get-shortcut count) | |
1831 (substring (elt submenu 0) 2)))) | |
1832 (if (listp submenu) | |
1833 (cons name (cdr submenu)) | |
1834 (apply 'vector (list name (cdr (append submenu nil))))))) | |
1835 ; (vconcat `[,name] (subseq submenu 1))))) | |
1836 | |
1837 (defun filesets-wrap-submenu (submenu-body) | |
1838 "Split long submenus." | |
1839 (let ((bl (length submenu-body))) | |
1840 (if (or (= filesets-max-submenu-length 0) | |
1841 (<= bl filesets-max-submenu-length)) | |
1842 submenu-body | |
1843 (let* ((result nil) | |
1844 (factor (ceiling (/ (float bl) | |
1845 filesets-max-submenu-length)))) | |
1846 (do ((data submenu-body (cdr data)) | |
1847 (n 1 (+ n 1)) | |
1848 (count 0 (+ count factor))) | |
1849 ((or (> count bl) | |
1850 (null data))) | |
1851 ; (let ((sl (subseq submenu-body count | |
1852 (let ((sl (filesets-sublist submenu-body count | |
1853 (let ((x (+ count factor))) | |
1854 (if (>= bl x) | |
1855 x | |
1856 nil))))) | |
1857 (when sl | |
1858 (setq result | |
1859 (append | |
1860 result | |
1861 (if (= (length sl) 1) | |
1862 (if filesets-menu-shortcuts-flag | |
1863 (list (filesets-remake-shortcut n (car sl))) | |
1864 sl) | |
1865 `((,(concat | |
1866 (filesets-get-shortcut n) | |
1867 (let ((rv "")) | |
1868 (do ((x sl (cdr x))) | |
1869 ((null x)) | |
1870 (let ((y (concat (elt (car x) 0) | |
1871 (if (null (cdr x)) | |
1872 "" | |
1873 ", ")))) | |
1874 (setq rv | |
1875 (concat | |
1876 rv | |
1877 (if filesets-menu-shortcuts-flag | |
1878 (substring y 2) | |
1879 y))))) | |
1880 (if (> (length rv) | |
1881 filesets-max-entry-length) | |
1882 (concat | |
1883 (substring rv 0 filesets-max-entry-length) | |
1884 " ...") | |
1885 rv))) | |
1886 ,@sl)))))))) | |
1887 result)))) | |
1888 | |
1889 (defun filesets-get-menu-epilog (something &optional | |
1890 mode lookup-name rebuild-flag) | |
1891 "Get submenu epilog for SOMETHING (usually a fileset). | |
1892 If mode is :tree or :ingroup, SOMETHING is some weird construct and | |
1893 LOOKUP-NAME is used as lookup name for retrieving fileset specific settings." | |
1894 (case mode | |
1895 ((:tree) | |
1896 `("---" | |
1897 ["Close all files" (filesets-close ',mode ',something ',lookup-name)] | |
1898 ["Run Command" (filesets-run-cmd nil ',something ',mode)] | |
1899 [,(format "Browse with `%s'" (filesets-browser-name)) | |
1900 (filesets-browse-dir ',(car something))] | |
1901 ,@(when rebuild-flag | |
1902 `(["Rebuild this submenu" | |
1903 (filesets-rebuild-this-submenu ',lookup-name)])))) | |
1904 ((:ingroup) | |
1905 `("---" | |
1906 ["Close all files" (filesets-close ',mode ',something ',lookup-name)] | |
1907 ["Run Command" (filesets-run-cmd nil ',something ',mode)] | |
1908 ,@(when rebuild-flag | |
1909 `(["Rebuild this submenu" | |
1910 (filesets-rebuild-this-submenu ',lookup-name)])))) | |
1911 ((:pattern) | |
1912 `("---" | |
1913 ["Close all files" (filesets-close ',mode ',something)] | |
1914 ["Run Command" (filesets-run-cmd nil ',something ',mode)] | |
1915 [,(format "Browse with `%s'" (filesets-browser-name)) | |
1916 ,(list 'filesets-browse-dir | |
1917 (filesets-entry-get-pattern--dir | |
1918 (filesets-entry-get-pattern | |
1919 (filesets-get-fileset-from-name something ':pattern))))] | |
1920 ; [,(concat (if filesets-menu-shortcuts-flag | |
1921 ; (concat "Con" filesets-menu-shortcuts-marker "vert") | |
1922 ; "Convert") | |
1923 ; " :pattern to :files") | |
1924 ; ,(list (function filesets-convert-patterns) something)] | |
1925 ,@(when rebuild-flag | |
1926 `(["Rebuild this submenu" | |
1927 (filesets-rebuild-this-submenu ',lookup-name)])))) | |
1928 ((:files) | |
1929 `("---" | |
1930 [,(concat "Close all files") (filesets-close ',mode ',something)] | |
1931 ["Run Command" (filesets-run-cmd nil ',something ',mode)] | |
1932 ["Add current buffer" | |
1933 (filesets-add-buffer ',something (current-buffer))] | |
1934 ["Remove current buffer" | |
1935 (filesets-remove-buffer ',something (current-buffer))] | |
1936 ,@(when rebuild-flag | |
1937 `(["Rebuild this submenu" | |
1938 (filesets-rebuild-this-submenu ',lookup-name)])))) | |
1939 (t | |
1940 (filesets-error 'error "Filesets: malformed definition of " something)))) | |
1941 | |
1942 (defun filesets-ingroup-get-data (master pos &optional fun) | |
1943 "Access to `filesets-ingroup-patterns'. Extract data section." | |
1944 (let ((masterfile (file-name-nondirectory master)) | |
1945 (fn (or fun (lambda (a b) | |
1946 (and (stringp a) | |
1947 (stringp b) | |
1948 (string-match a b)))))) | |
1949 (some (lambda (x) | |
1950 (if (funcall fn (car x) masterfile) | |
1951 (nth pos x) | |
1952 nil)) | |
1953 filesets-ingroup-patterns))) | |
1954 | |
1955 (defun filesets-ingroup-get-pattern (master) | |
1956 "Access to `filesets-ingroup-patterns'. Extract patterns." | |
1957 (filesets-ingroup-get-data master 2)) | |
1958 | |
1959 (defun filesets-ingroup-get-remdupl-p (master) | |
1960 "Access to `filesets-ingroup-patterns'. Extract remove-duplicates-flag." | |
1961 (filesets-ingroup-get-data master 1)) | |
1962 | |
1963 (defun filesets-ingroup-collect-finder (patt case-sencitivep) | |
1964 "Helper function for `filesets-ingroup-collect'. Find pattern PATT." | |
1965 (let ((cfs case-fold-search) | |
1966 (rv (progn | |
1967 (setq case-fold-search (not case-sencitivep)) | |
1968 (re-search-forward patt nil t)))) | |
1969 (setq case-fold-search cfs) | |
1970 rv)) | |
1971 | |
1972 (defun filesets-ingroup-cache-get (master) | |
1973 "Access to `filesets-ingroup-cache'." | |
1974 (lax-plist-get filesets-ingroup-cache master)) | |
1975 | |
1976 (defun filesets-ingroup-cache-put (master file) | |
1977 "Access to `filesets-ingroup-cache'." | |
1978 (let* ((emaster (expand-file-name master)) | |
1979 (this (if file | |
1980 (cons file (filesets-ingroup-cache-get emaster)) | |
1981 nil))) | |
1982 (setq filesets-ingroup-cache | |
1983 (lax-plist-put filesets-ingroup-cache emaster this)))) | |
1984 | |
1985 (defun filesets-ingroup-collect-files (fs &optional remdupl-flag master depth) | |
1986 "Helper function for `filesets-ingroup-collect'. Collect file names." | |
1987 (let* ((master (or master | |
1988 (filesets-entry-get-master fs))) | |
1989 (remdupl-flag (or remdupl-flag | |
1990 (filesets-ingroup-get-remdupl-p master)))) | |
1991 (filesets-ingroup-cache-put master nil) | |
1992 (filesets-message 2 "Filesets: parsing %S" master) | |
1993 (let ((cmdpatts (filesets-ingroup-get-pattern master)) | |
1994 (count 0) | |
1995 (rv nil)) | |
1996 (if cmdpatts | |
1997 (dolist (this-def cmdpatts rv) | |
1998 (let* ((this-patt (filesets-alist-get this-def ':pattern nil t)) | |
1999 (this-name (filesets-alist-get this-def ':name "" t)) | |
2000 (this-pp (filesets-alist-get this-def ':preprocess nil t)) | |
2001 (this-mn (filesets-alist-get this-def ':match-number 1 t)) | |
2002 (this-sd (or depth | |
2003 (filesets-alist-get this-def ':scan-depth 0 t))) | |
2004 (this-csp (filesets-alist-get this-def ':case-sensitive nil t)) | |
2005 (this-fn (filesets-alist-get | |
2006 this-def ':get-file-name 'filesets-which-file t)) | |
2007 (this-stubp (filesets-alist-get this-def ':stubp nil t)) | |
2008 (this-stub-flag (filesets-alist-get this-def ':stub-flag nil t)) | |
2009 (flist nil) | |
2010 (lst nil)) | |
2011 (cond | |
2012 ((not this-patt) | |
2013 (filesets-error 'error "Filesets: malformed :ingroup definition " | |
2014 this-def)) | |
45130
cb1d1e1eb678
(filesets-ingroup-collect-files):
Richard M. Stallman <rms@gnu.org>
parents:
45012
diff
changeset
|
2015 ((< this-sd 0) |
cb1d1e1eb678
(filesets-ingroup-collect-files):
Richard M. Stallman <rms@gnu.org>
parents:
45012
diff
changeset
|
2016 nil) |
44934 | 2017 (t |
2018 (with-temp-buffer | |
2019 (insert-file-contents master) | |
2020 (goto-char (point-min)) | |
2021 (when this-pp | |
2022 (funcall this-pp)) | |
2023 (while (filesets-ingroup-collect-finder this-patt this-csp) | |
2024 (let* ((txt (match-string this-mn)) | |
2025 (f (funcall this-fn master txt))) | |
2026 (when (and f | |
2027 (not (member f flist)) | |
2028 (or (not remdupl-flag) | |
2029 (not (member* | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
2030 f filesets-ingroup-files |
44934 | 2031 :test 'filesets-files-equalp)))) |
2032 (let ((no-stub-flag | |
2033 (and (not this-stub-flag) | |
2034 (if this-stubp | |
2035 (not (funcall this-stubp master f)) | |
2036 t)))) | |
2037 (setq count (+ count 1)) | |
2038 (setq flist (cons f flist)) | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
2039 (setq filesets-ingroup-files |
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
2040 (cons f filesets-ingroup-files)) |
44934 | 2041 (when no-stub-flag |
2042 (filesets-ingroup-cache-put master f)) | |
2043 (setq lst (append lst (list f)))))))) | |
2044 (when lst | |
2045 (setq rv | |
2046 (nconc rv | |
2047 (mapcar (lambda (this) | |
2048 `((,this ,this-name) | |
2049 ,@(filesets-ingroup-collect-files | |
2050 fs remdupl-flag this | |
2051 (- this-sd 1)))) | |
2052 lst)))))))) | |
2053 (filesets-message 2 "Filesets: no patterns defined for %S" master))))) | |
2054 | |
2055 (defun filesets-ingroup-collect-build-menu (fs flist &optional other-count) | |
2056 "Helper function for `filesets-ingroup-collect'. Build the menu. | |
2057 FS is a fileset's name. FLIST is a list returned by | |
2058 `filesets-ingroup-collect-files'." | |
2059 (if (null flist) | |
2060 nil | |
2061 (let ((count 0) | |
2062 (fsn fs) | |
2063 (rv nil)) | |
2064 (dolist (this flist rv) | |
2065 (setq count (+ count 1)) | |
2066 (let* ((def (if (listp this) (car this) (list this ""))) | |
2067 (files (if (listp this) (cdr this) nil)) | |
2068 (master (nth 0 def)) | |
2069 (name (nth 1 def)) | |
2070 (nm (concat (filesets-get-shortcut (if (or (not other-count) files) | |
2071 count other-count)) | |
2072 (if (or (null name) (equal name "")) | |
2073 "" | |
2074 (format "%s: " name)) | |
2075 (file-name-nondirectory master)))) | |
2076 (setq rv | |
2077 (append rv | |
2078 (if files | |
2079 `((,nm | |
2080 [,(concat "Inclusion Group: " | |
2081 (file-name-nondirectory master)) | |
2082 (filesets-open ':ingroup ',master ',fsn)] | |
2083 "---" | |
2084 [,master (filesets-file-open nil ',master ',fsn)] | |
2085 "---" | |
2086 ,@(let ((count 0)) | |
2087 (mapcar | |
2088 (lambda (this) | |
2089 (setq count (+ count 1)) | |
2090 (let ((ff (filesets-ingroup-collect-build-menu | |
2091 fs (list this) count))) | |
2092 (if (= (length ff) 1) | |
2093 (car ff) | |
2094 ff))) | |
2095 files)) | |
2096 ,@(filesets-get-menu-epilog master ':ingroup fsn))) | |
2097 `([,nm (filesets-file-open nil ',master ',fsn)]))))))))) | |
2098 | |
2099 (defun filesets-ingroup-collect (fs remdupl-flag master &optional depth) | |
2100 "Collect names of included files & build submenu." | |
2101 (filesets-ingroup-cache-put master nil) | |
2102 (filesets-message 2 "Filesets: parsing %S" master) | |
2103 (filesets-ingroup-collect-build-menu | |
2104 fs | |
2105 (filesets-ingroup-collect-files fs remdupl-flag master))) | |
2106 | |
2107 (defun filesets-build-ingroup-submenu (lookup-name master) | |
2108 "Build a :ingroup submenu for file MASTER." | |
2109 (if (file-readable-p master) | |
2110 (let ((remdupl-flag (filesets-ingroup-get-remdupl-p master))) | |
45012
161015ebadc0
(filesets-running-xemacs): Make defvar unconditional.
Richard M. Stallman <rms@gnu.org>
parents:
44973
diff
changeset
|
2111 (setq filesets-ingroup-files (list master)) |
44934 | 2112 (filesets-ingroup-collect lookup-name remdupl-flag master)) |
2113 (if filesets-be-docile-flag | |
2114 (progn | |
2115 (message "Filesets: can't parse %s" master) | |
2116 nil) | |
2117 (filesets-error 'error "Filesets: can't parse " master)))) | |
2118 | |
2119 (defun filesets-build-dir-submenu-now (level depth entry lookup-name dir patt fd | |
2120 &optional rebuild-flag) | |
2121 "Helper function for `filesets-build-dir-submenu'." | |
2122 ;;(filesets-message 3 "Filesets: scanning %s" dir) | |
2123 (if (or (= depth 0) | |
2124 (< level depth)) | |
2125 (let* ((dir (file-name-as-directory dir)) | |
2126 (header `([,(concat "Tree: " | |
2127 (if (= level 0) | |
2128 dir | |
2129 (concat ".../" | |
2130 (file-name-as-directory | |
2131 (file-name-nondirectory | |
2132 (directory-file-name dir)))))) | |
2133 ,(list (function filesets-open) | |
2134 ':tree | |
2135 `(quote (,dir ,patt)) | |
2136 lookup-name)] | |
2137 "---")) | |
2138 (dirlist (filesets-directory-files dir patt nil nil fd)) | |
2139 (subdirs (filesets-filter-dir-names dirlist)) | |
2140 (count 0) | |
2141 (dirsmenu (mapcar | |
2142 (lambda (x) | |
2143 (setq count (+ count 1)) | |
2144 (let* ((x (file-name-as-directory x)) | |
2145 (xx (concat dir x)) | |
2146 (dd (filesets-build-dir-submenu-now | |
2147 (+ level 1) depth entry | |
2148 lookup-name xx patt fd)) | |
2149 (nm (concat (filesets-get-shortcut count) | |
2150 x))) | |
2151 (if dd | |
2152 `(,nm ,@dd) | |
2153 `[,nm ,(list 'filesets-browse-dir xx)]))) | |
2154 subdirs)) | |
2155 (files (filesets-filter-dir-names dirlist t)) | |
2156 (filesmenu (mapcar (lambda (x) | |
2157 (setq count (+ count 1)) | |
2158 `[,(concat (filesets-get-shortcut count) | |
2159 x) | |
2160 (filesets-file-open nil | |
2161 (quote ,(concat dir x)) | |
2162 (quote ,lookup-name))]) | |
2163 files))) | |
2164 (append header | |
2165 (filesets-wrap-submenu | |
2166 (append | |
2167 dirsmenu | |
2168 filesmenu)) | |
2169 (filesets-get-menu-epilog `(,dir ,patt) ':tree | |
2170 lookup-name rebuild-flag))) | |
2171 nil)) | |
2172 | |
2173 (defun filesets-build-dir-submenu (entry lookup-name dir patt) | |
2174 "Build a :tree submenu named LOOKUP-NAME with base directory DIR including | |
2175 all files matching PATT for filesets ENTRY." | |
2176 (let ((fd (filesets-entry-get-filter-dirs-flag entry)) | |
2177 (depth (or (filesets-entry-get-tree-max-level entry) | |
2178 filesets-tree-max-level))) | |
2179 (filesets-build-dir-submenu-now 0 depth entry lookup-name dir patt fd t))) | |
2180 | |
2181 (defun filesets-build-submenu (count lookup-name entry) | |
2182 "Build submenu for the fileset ENTRY named LOOKUP-NAME. | |
2183 Construct a shortcut from COUNT." | |
2184 (let ((lookup-name (or lookup-name | |
2185 (filesets-data-get-name entry)))) | |
2186 (message "Filesets: %s" lookup-name) | |
2187 (let ((mode (filesets-entry-mode entry)) | |
2188 (filesets-verbosity (filesets-entry-get-verbosity entry)) | |
2189 (this-lookup-name (concat (filesets-get-shortcut count) | |
2190 lookup-name))) | |
2191 (case mode | |
2192 ((:file) | |
2193 (let* ((file (filesets-entry-get-file entry))) | |
2194 `[,this-lookup-name | |
2195 (filesets-file-open nil ',file ',lookup-name)])) | |
2196 (t | |
2197 `(,this-lookup-name | |
2198 ,@(case mode | |
2199 ((:pattern) | |
2200 (let* ((files (filesets-get-filelist entry mode 'on-ls)) | |
2201 (dirpatt (filesets-entry-get-pattern entry)) | |
2202 (pattname (apply 'concat (cons "Pattern: " dirpatt))) | |
2203 (count 0)) | |
2204 ;;(filesets-message 3 "Filesets: scanning %S" pattname) | |
2205 `([,pattname | |
2206 ,(list (function filesets-open) mode lookup-name)] | |
2207 "---" | |
2208 ,@(filesets-wrap-submenu | |
2209 (mapcar | |
2210 (lambda (x) | |
2211 (setq count (+ count 1)) | |
2212 `[,(concat (filesets-get-shortcut count) | |
2213 (file-name-nondirectory x)) | |
2214 (filesets-file-open nil ',x ',lookup-name)]) | |
2215 files)) | |
2216 ,@(filesets-get-menu-epilog lookup-name mode | |
2217 lookup-name t)))) | |
2218 ((:ingroup) | |
2219 (let* ((master (filesets-entry-get-master entry))) | |
2220 ;;(filesets-message 3 "Filesets: parsing %S" master) | |
2221 `([,(concat "Inclusion Group: " | |
2222 (file-name-nondirectory master)) | |
2223 (filesets-open ',mode ',master ',lookup-name)] | |
2224 "---" | |
2225 [,master (filesets-file-open nil ',master ',lookup-name)] | |
2226 "---" | |
2227 ,@(filesets-wrap-submenu | |
2228 (filesets-build-ingroup-submenu lookup-name master)) | |
2229 ,@(filesets-get-menu-epilog master mode lookup-name t)))) | |
2230 ((:tree) | |
2231 (let* ((dirpatt (filesets-entry-get-tree entry)) | |
2232 (dir (car dirpatt)) | |
2233 (patt (cadr dirpatt))) | |
2234 (filesets-build-dir-submenu entry lookup-name dir patt))) | |
2235 ((:files) | |
2236 (let ((files (filesets-get-filelist entry mode 'on-open-all)) | |
2237 (count 0)) | |
2238 `([,(concat "Files: " lookup-name) | |
2239 (filesets-open ',mode ',lookup-name)] | |
2240 "---" | |
2241 ,@(filesets-wrap-submenu | |
2242 (mapcar | |
2243 (lambda (x) | |
2244 (setq count (+ count 1)) | |
2245 `[,(concat (filesets-get-shortcut count) | |
2246 (file-name-nondirectory x)) | |
2247 (filesets-file-open nil ',x ',lookup-name)]) | |
2248 (filesets-conditional-sort | |
2249 files | |
2250 (function file-name-nondirectory)))) | |
2251 ,@(filesets-get-menu-epilog lookup-name mode | |
2252 lookup-name t))))))))))) | |
2253 | |
2254 (defun filesets-remove-from-ubl (&optional buffer) | |
2255 "BUFFER or current-buffer require update of the filesets menu." | |
2256 (let ((b (or buffer | |
2257 (current-buffer)))) | |
2258 (if (member b filesets-updated-buffers) | |
2259 (setq filesets-updated-buffers | |
2260 (delete b filesets-updated-buffers))))) | |
2261 | |
2262 (defun filesets-build-menu-now (from-scratch-flag) | |
2263 "Update the filesets menu. | |
2264 Build all new if FROM-SCRATCH-FLAG is non-nil. (To really build from the | |
2265 bottom up, set `filesets-submenus' to nil, first.)" | |
2266 (when (or from-scratch-flag | |
2267 filesets-has-changed-flag | |
2268 (not filesets-menu-cache)) | |
2269 (setq filesets-menu-cache nil) | |
2270 (setq filesets-has-changed-flag nil) | |
2271 (setq filesets-updated-buffers nil) | |
2272 (setq filesets-update-cache-file-flag t) | |
2273 (do ((data (filesets-conditional-sort filesets-data (function car)) | |
2274 (cdr data)) | |
2275 (count 1 (+ count 1))) | |
2276 ((null data)) | |
2277 (let* ((this (car data)) | |
2278 (name (filesets-data-get-name this)) | |
2279 (cached (lax-plist-get filesets-submenus name)) | |
2280 (submenu (or cached | |
2281 (filesets-build-submenu count name this)))) | |
2282 (unless cached | |
2283 (setq filesets-submenus | |
2284 (lax-plist-put filesets-submenus name submenu))) | |
2285 (unless (filesets-entry-get-dormant-flag this) | |
2286 (setq filesets-menu-cache | |
2287 (append filesets-menu-cache (list submenu)))))) | |
2288 (when filesets-cache-save-often-flag | |
2289 (filesets-menu-cache-file-save-maybe))) | |
2290 (let ((cb (current-buffer))) | |
2291 (when (not (member cb filesets-updated-buffers)) | |
2292 (filesets-add-submenu | |
2293 filesets-menu-path | |
2294 `(,filesets-menu-name | |
2295 ("# Filesets" | |
2296 ["Edit Filesets" filesets-edit] | |
2297 ["Save Filesets" filesets-save-config] | |
2298 ["Save Menu Cache" filesets-menu-cache-file-save] | |
2299 ["Rebuild Menu" filesets-build-menu] | |
2300 ["Customize" filesets-customize] | |
2301 ["About" filesets-info]) | |
2302 ,(filesets-get-cmd-menu) | |
2303 "---" | |
2304 ,@filesets-menu-cache) | |
2305 filesets-menu-before | |
2306 filesets-menu-in-menu) | |
2307 (setq filesets-updated-buffers | |
2308 (cons cb filesets-updated-buffers)) | |
2309 (message nil) | |
2310 ;;(message "Filesets updated: %s" cb) | |
2311 ))) | |
2312 | |
2313 (defun filesets-build-menu-maybe () | |
2314 "Update the filesets menu." | |
2315 (interactive) | |
2316 (filesets-build-menu-now nil)) | |
2317 | |
2318 (defun filesets-build-menu () | |
2319 "Force rebuild of the filesets menu." | |
2320 (interactive) | |
2321 ;(setq filesets-submenus nil) | |
2322 (filesets-reset-fileset) | |
2323 (filesets-build-menu-now t) | |
2324 (filesets-menu-cache-file-save-maybe)) | |
2325 | |
2326 (defun filesets-rebuild-this-submenu (fileset) | |
2327 "Force rebuild of FILESET submenu." | |
2328 (filesets-reset-fileset fileset) | |
2329 (filesets-build-menu-now t)) | |
2330 | |
2331 (defun filesets-menu-cache-file-save-maybe (&optional simply-do-it) | |
2332 "Write filesets' cache file. | |
2333 If SIMPLY-DO-IT is non-nil, the cache file will be written no matter if | |
2334 fileset thinks this is necessary or not." | |
2335 (when (and (not (equal filesets-menu-cache-file "")) | |
2336 (or simply-do-it | |
2337 filesets-update-cache-file-flag)) | |
2338 (when (file-exists-p filesets-menu-cache-file) | |
2339 (delete-file filesets-menu-cache-file)) | |
2340 ;;(message "Filesets: saving menu cache") | |
2341 (with-temp-buffer | |
2342 (dolist (this filesets-menu-cache-contents) | |
2343 (if (get this 'custom-type) | |
2344 (progn | |
2345 (insert (format "(setq-default %s '%S)" this (eval this))) | |
2346 (when filesets-menu-ensure-use-cached | |
2347 (newline) | |
2348 (insert (format "(setq %s (cons '%s %s))" | |
2349 'filesets-ignore-next-set-default | |
2350 this | |
2351 'filesets-ignore-next-set-default)))) | |
2352 (insert (format "(setq %s '%S)" this (eval this)))) | |
2353 (newline 2)) | |
2354 (insert (format "(setq filesets-cache-version %S)" filesets-version)) | |
2355 (newline 2) | |
2356 (when filesets-cache-hostname-flag | |
2357 (insert (format "(setq filesets-cache-hostname %S)" (system-name))) | |
2358 (newline 2)) | |
2359 (run-hooks 'filesets-cache-fill-content-hooks) | |
2360 (write-file filesets-menu-cache-file)) | |
2361 (setq filesets-has-changed-flag nil) | |
2362 (setq filesets-update-cache-file-flag nil))) | |
2363 | |
2364 (defun filesets-menu-cache-file-save () | |
2365 "Save filesets' menu cache file." | |
2366 (interactive) | |
2367 (filesets-menu-cache-file-save-maybe t)) | |
2368 | |
2369 (defun filesets-update-cleanup () | |
2370 "Rebuild the menu and save the cache file after updating user data." | |
2371 (interactive) | |
2372 (message "Filesets v%s: updating menu & cache from version %s" | |
2373 filesets-version (or filesets-cache-version "???")) | |
2374 (filesets-build-menu) | |
2375 (filesets-menu-cache-file-save-maybe) | |
2376 (filesets-menu-cache-file-load)) | |
2377 | |
2378 (defun filesets-update-pre010505 () | |
2379 (let ((msg | |
2380 "Filesets: manual editing of user data required! | |
2381 | |
2382 Filesets has detected that you were using an older version before, | |
2383 which requires some manual updating. Type 'y' for editing the startup | |
2384 file now. | |
2385 | |
2386 The layout of `filesets-data' has changed. Please delete your cache file | |
2387 and edit your startup file as shown below: | |
2388 | |
2389 1. `filesets-data': Edit all :pattern filesets in your startup file and | |
2390 transform all entries as shown in this example: | |
2391 | |
2392 \(\"Test\" (:pattern \"~/dir/^pattern$\")) | |
2393 --> \(\"Test\" (:pattern \"~/dir/\" \"^pattern$\")) | |
2394 | |
2395 2. `filesets-data': Change all occurances of \":document\" to \":ingroup\": | |
2396 | |
2397 \(\(\"Test\" \(:document \"~/dir/file\")) | |
2398 --> \(\(\"Test\" \(:ingroup \"~/dir/file\")) | |
2399 | |
2400 3. `filesets-subdocument-patterns': If you already modified the variable | |
2401 previously called `filesets-subdocument-patterns', change its name to | |
2402 `filesets-ingroup-patterns'. | |
2403 | |
2404 4. `filesets-menu-cache-contents': If you already modified this | |
2405 variable, change the entry `filesets-subdocument--cache' to | |
2406 `filesets-ingroup-cache'. | |
2407 | |
2408 5. Type M-x filesets-update-cleanup and restart Emacs. | |
2409 | |
2410 We apologize for the inconvenience.")) | |
2411 (let* ((cf (or custom-file user-init-file))) | |
2412 (switch-to-buffer-other-frame "*Filesets update*") | |
2413 (insert msg) | |
2414 (when (y-or-n-p (format "Edit startup (%s) file now? " cf)) | |
2415 (find-file-other-window cf)) | |
2416 (filesets-error 'error msg)))) | |
2417 | |
2418 (defun filesets-update (version cached-version) | |
2419 "Do some cleanup after updating filesets.el." | |
2420 (cond | |
2421 ((or (not cached-version) | |
2422 (string< cached-version "1.5.5") | |
2423 (boundp 'filesets-subdocument-patterns)) | |
2424 (filesets-update-pre010505))) | |
2425 (filesets-update-cleanup)) | |
2426 | |
2427 (defun filesets-menu-cache-file-load () | |
2428 "Load filesets' menu cache file." | |
2429 (cond | |
2430 ((and (not (equal filesets-menu-cache-file "")) | |
2431 (file-readable-p filesets-menu-cache-file)) | |
2432 (load-file filesets-menu-cache-file) | |
2433 (if (and (equal filesets-cache-version filesets-version) | |
2434 (if filesets-cache-hostname-flag | |
2435 (equal filesets-cache-hostname (system-name)) | |
2436 t)) | |
2437 (progn | |
2438 (setq filesets-update-cache-file-flag nil) | |
2439 t) | |
2440 (filesets-update filesets-version filesets-cache-version))) | |
2441 (t | |
2442 (setq filesets-update-cache-file-flag t) | |
2443 nil))) | |
2444 | |
2445 (defun filesets-exit () | |
2446 (filesets-menu-cache-file-save-maybe)) | |
2447 | |
2448 (defun filesets-init () | |
2449 "Filesets initialization. | |
2450 Set up hooks, load the cache file -- if existing -- and build the menu." | |
2451 (add-hook (if filesets-running-xemacs 'activate-menubar-hook 'menu-bar-update-hook) | |
2452 (function filesets-build-menu-maybe)) | |
2453 (add-hook 'kill-buffer-hook (function filesets-remove-from-ubl)) | |
2454 (add-hook 'first-change-hook (function filesets-reset-filename-on-change)) | |
2455 (add-hook 'kill-emacs-hook (function filesets-exit)) | |
2456 (if (filesets-menu-cache-file-load) | |
2457 (progn | |
2458 (filesets-build-menu-maybe) | |
2459 ;;Well, normally when we use XEmacs <= 21.4, custom.el is loaded | |
2460 ;;after init.el. This more or less ignores the next | |
2461 ;;`filesets-data-set-default' | |
2462 (if filesets-menu-ensure-use-cached | |
2463 (setq filesets-menu-use-cached-flag t))) | |
2464 (filesets-build-menu))) | |
2465 | |
2466 | |
2467 ;;; run | |
2468 (filesets-init) | |
2469 | |
2470 (provide 'filesets) | |
2471 | |
2472 ;;; Local Variables: | |
2473 ;;; time-stamp-format:"%:y-%02m-%02d" | |
2474 ;;; sentence-end-double-space:t | |
2475 ;;; End: | |
2476 | |
2477 ;;; filesets.el ends here |