Homepage | Project |
filesets.el
makes it easy to open frequently used files. There are
several ways of working on whole filesets. Files can be opened or closed
at once; and you can run arbitrary programs or functions on them. Files
can be opened with external programs/viewers.
This package is inspired by the Alpha editor's filesets. filesets.el
adds a new menu to the menu bar, each submenu of which holds a list of
files. Use this package for
A fileset is either:
"~/bashrc"
, "~/bash_profile"
, ".xinitrc"
etc.)
MyIndex
or its subpages up to 3 level deep)
Currently supported modes for inclusion groups:
Elisp
Emacs-Wiki
(Filesets doesn't use `emacs-wiki-name-regexp' by
default; modify `filesets-ingroup-patterns' to reflect your own
modifications to emacs-wiki's markup.)
LaTeX
Further modes can easily be added by editing `filesets-ingroup-patterns'. If you make interesting additions, please email them to the maintainer.
Put (require 'filesets)
into your startup file and select "Edit
Filesets" from the filesets menu. If you change your filesets on the
fly, don't forget to press "Save Filesets".
The best way to create new filesets is via the "Customize" menu in the "Menubar/Filesets/Filesets" submenu. You can of course edit the variable `filesets-data' by hand but this is cumbersome and error prone as this variables layout was optimized for modification via Emacs' customize feature.
Every filesets can have its own function for opening or closing files. This can be useful for setting fileset specific variables like tab width and the like.
This variable contains the definition of filesets. Changes to this variable will take effect after rebuilding the menu. Normally this is done automatically, though.
Caveat: Fileset names have to be unique.
Example definition:
'(("My Wiki" (:ingroup "~/Etc/My-Wiki/WikiContents")) ("My Homepage" (:pattern "~/public_html/" "^.+\\.html$") (:open filesets-find-file)) ("User Configuration" (:files "~/.xinitrc" "~/.bashrc" "~/.bash_profile")) ("HOME" (:tree "~" "^[^.].*[^~]$") (:filter-dirs-flag t)))
`filesets-data' is a list of (NAME-AS-STRING . DEFINITION), DEFINITION being an association list with the fields:
Either :files, :pattern, :tree, or :ingroup must be supplied. :files overrules :tree, :tree overrules :pattern, :pattern overrules :ingroup, i.e. these tags are mutually exclusive. The fields :open and :save are optional.
In conjunction with the :tree tag, :save is void. :open refers to the function used for opening files in a directory, not for opening the directory. For browsing directories, `filesets-browse-dir-function' is used.
Before using :ingroup, make sure that the file type is already defined in `filesets-ingroup-patterns'.
Press on the first item in the submenu to open all files at once. Select "Close all files" from the filesets' submenu when you have finished your work.
Sometimes the data in the menu is outdated -- e.g. when adding a new file to a directory. In this case select "Rebuild this submenu" to rebuild the menu of a specific filesets, or select "Rebuild menu" from "Menubar/Filesets/Filesets" to rebuild the whole menu.
New in version 2.0: Some fileset types (:tree and :pattern) have a submenu called "File Commands". Use the commands in this submenu to add new directories or files.
Edit `filesets-commands' in order to add new commands for working on whole filesets.
The default value is:
`(("Query Replace" query-replace (filesets-cmd-query-replace-getargs)) ("Query Replace (regexp)" query-replace-regexp (filesets-cmd-query-replace-getargs)) ("Grep <<selection>>" "grep" ("-n " filesets-get-quoted-selection " " "<<file-name>>")) ("Run Shell Command" filesets-cmd-shell-command (filesets-cmd-shell-command-getargs)))
Technically, `filesets-commands' is an association list of names, functions, and an argument list (or a function that returns one) to be run on a filesets' files. The layout is ((NAME COMMAND/FUNCTION LIST-OF-ARGS) ...).
The argument list may contain one of the following pseudo arguments:
The following options are supported:
Filesets can make use of external viewers for displaying or converting non-text files. An external viewer can be a program that displays a file (e.g. xpdf for PDF files), or a program that converts the file's contents into text, which can then be displayed in an Emacs buffer (e.g. rtf2htm and w3 for displaying HTML or RTF files).
It is very likely that you have to modify this variable in order to adapt it to your environment. Do this by editing `filesets-external-viewers', which is an association list of file patterns and external viewers for use with `filesets-find-or-display-file'.
This association list has the form ((FILE-PATTERN VIEWER PROPERTIES) ...), VIEWER being either a function or a command name as string.
Properties is an association list determining filesets' behaviour in several conditions. Choose one from this list:
In order to view pdf or rtf files in an Emacs buffer, you could use something like this:
("^.+\\.pdf$" "pdftotext" ((:capture-output t) (:args ("%S - | fmt -w " window-width)) (:ignore-on-read-text t) (:constraintp (lambda () (and (filesets-which-command-p "pdftotext") (filesets-which-command-p "fmt")))))) ("^.+\\.rtf$" "rtf2htm" ((:capture-output t) (:args ("%S 2> /dev/null | w3m -dump -T text/html")) (:ignore-on-read-text t) (:constraintp (lambda () (and (filesets-which-command-p "rtf2htm") (filesets-which-command-p "w3m"))))))
Rebuilding the menu may take time and consume memory if you use filesets a lot. In order to minimize the delay at startup, the menu data can be cached/saved between editing sessions. Basically you could store any variable in filesets' cache by editing `filesets-menu-cache-contents'.
By default, the cache is saved on exit. This means if Emacs crashes, modifications are lost. Set `filesets-cache-save-often-flag' to t to save the cache on every significant change of `filesets-data'.
Although filesets are supposed to be manipulated via the menu, you can also use the following interactive function from the command line--e.g. when running Emacs on a terminal.
(fset 'fsfind-file #'filesets-find-or-display-file') (add-hook 'dired-setup-keys-hook #'(lambda () (define-key dired-mode-map "f" #'(lambda (&optional coding-system) (interactive) (let ((filesets-open-file-function #'dired-advertised-find-file)) (filesets-find-or-display-file (dired-get-filename)))))))
Apart from the already mentioned variables the following ones might be important for customizing filesets.el to your needs:
(c) 2003 Thomas Link (last updated Mar 20 2003) | home | top |