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