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