;;; filesets.el --- handle group of files
-;; Copyright (C) 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
;; Author: Thomas Link <t.link@gmx.at>
;; Maintainer: FSF
;; GNU General Public License for more details.
;; A copy of the GNU General Public License can be obtained from this
-;; program's author or from the Free Software Foundation, Inc., 675 Mass
-;; Ave, Cambridge, MA 02139, USA.
+;; program's author or from the Free Software Foundation, Inc.,
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
(defvar filesets-version "1.8.4")
(defvar filesets-homepage
(defvar filesets-menu-ensure-use-cached
(and filesets-running-xemacs
- (not (emacs-version>= 21 5)))
+ (if (fboundp 'emacs-version>=)
+ (not (emacs-version>= 21 5))))
"Make sure (X)Emacs uses filesets' cache.
Well, if you use XEmacs (prior to 21.5?) custom.el is loaded after
; (customize-set-variable var val))
; (filesets-build-menu))
+;; It seems this is a workaround for the XEmacs issue described in the
+;; doc-string of filesets-menu-ensure-use-cached. Under Emacs this is
+;; essentially just `set-default'.
(defun filesets-set-default (sym val &optional init-flag)
- "Set-default wrapper function used in conjunction with `defcustom'."
+ "Set-default wrapper function used in conjunction with `defcustom'.
+If SYM is in the list `filesets-ignore-next-set-default', delete
+it from that list, and return nil. Otherwise, set the value of
+SYM to VAL and return t. If INIT-FLAG is non-nil, set with
+`custom-initialize-set', otherwise with `set-default'."
(let ((ignore-flag (member sym filesets-ignore-next-set-default)))
(if ignore-flag
(setq filesets-ignore-next-set-default
:type 'sexp
:group 'filesets)
-(if filesets-running-xemacs
- (progn
- (defcustom filesets-menu-path nil
- "*The menu under which the filesets menu should be inserted.
-XEmacs specific; see `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type 'sexp
- :group 'filesets)
-
- (defcustom filesets-menu-before "File"
- "*The name of a menu before which this menu should be added.
-XEmacs specific; see `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type 'sexp
- :group 'filesets)
-
- (defcustom filesets-menu-in-menu nil
- "*Use that instead of `current-menubar' as the menu to change.
-XEmacs specific; see `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type 'sexp
- :group 'filesets))
- (defvar filesets-menu-path nil)
- (defvar filesets-menu-before nil)
- (defvar filesets-menu-in-menu nil))
+(defcustom filesets-menu-path nil
+ "*The menu under which the filesets menu should be inserted.
+See `add-submenu' for documentation."
+ :set (function filesets-set-default)
+ :type 'sexp
+ :group 'filesets)
+
+(defcustom filesets-menu-before "File"
+ "*The name of a menu before which this menu should be added.
+See `add-submenu' for documentation."
+ :set (function filesets-set-default)
+ :type 'sexp
+ :group 'filesets)
+
+(defcustom filesets-menu-in-menu nil
+ "*Use that instead of `current-menubar' as the menu to change.
+See `add-submenu' for documentation."
+ :set (function filesets-set-default)
+ :type 'sexp
+ :group 'filesets)
(defcustom filesets-menu-shortcuts-flag t
"*Non-nil means to prepend menus with hopefully unique shortcuts."
(defcustom filesets-menu-cache-file
(if filesets-running-xemacs
"~/.xemacs/filesets-cache.el"
- "~/.filesets-cache.el")
+ "~/.emacs.d/filesets-cache.el")
"*File to be used for saving the filesets menu between sessions.
Set this to \"\", to disable caching of menus.
Don't forget to check out `filesets-menu-ensure-use-cached'."
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:
+Properties is an association list determining filesets' behavior in
+several conditions. Choose one from this list:
:ignore-on-open-all ... Don't open files of this type automatically --
i.e. on open-all-files-events or when running commands
;;; Emacs compatibility
(eval-and-compile
(if filesets-running-xemacs
- (progn
- (fset 'filesets-error 'error)
- (fset 'filesets-add-submenu 'add-submenu))
+ (fset 'filesets-error 'error)
(require 'easymenu)
"`error' wrapper."
(error (mapconcat 'identity args " ")))
- ;; This should work for 21.1 Emacs
- (defun filesets-add-submenu (menu-path submenu &optional
- before in-menu)
- "`easy-menu-define' wrapper."
- (easy-menu-define
- filesets-submenu global-map "Filesets menu" submenu))
))
(defun filesets-filter-dir-names (lst &optional negative)
(name (or name
(completing-read
(format "Add '%s' to fileset: " buffer)
- filesets-data nil t)))
- (entry (assoc name filesets-data)))
+ filesets-data nil)))
+ (entry (or (assoc name filesets-data)
+ (when (y-or-n-p
+ (format "Fileset %s does not exist. Create it?"
+ name))
+ (progn
+ (add-to-list 'filesets-data (list name '(:files)))
+ (message
+ "Fileset %s created. Call `M-x filesets-save-config' to save."
+ name)
+ (car filesets-data))))))
(if entry
(let* ((files (filesets-entry-get-files entry))
(this (buffer-file-name buffer))
(filesets-menu-cache-file-save-maybe)))
(let ((cb (current-buffer)))
(when (not (member cb filesets-updated-buffers))
- (filesets-add-submenu
+ (add-submenu
filesets-menu-path
`(,filesets-menu-name
("# Filesets"