X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fcus-dep.el;h=98c8048a7d9011b8c9165868b255221fca9bc0e4;hb=63b66f8fe2d4b883aaec0ac9689262493bfc411d;hp=81cb4249f1e55d7c64700335548a4c169f13b7c3;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git.1 diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el index 81cb424..98c8048 100644 --- a/lisp/cus-dep.el +++ b/lisp/cus-dep.el @@ -4,8 +4,8 @@ ;; ;; Author: Per Abrahamsen , then ;; Richard Stallman , then -;; Hrvoje Niksic (rewritten for XEmacs) -;; Maintainer: Hrvoje Niksic +;; Hrvoje Niksic (rewritten for XEmacs) +;; Maintainer: Hrvoje Niksic ;; Keywords: internal ;; This file is part of XEmacs. @@ -31,7 +31,8 @@ ;;; Commentary: ;; This file generates the custom-load files, loaded by cus-load.el. -;; The only entry point is `Custom-make-dependencies'. +;; Entry points are `Custom-make-dependencies' and +;; `Custom-make-one-dependency'. ;; It works by scanning all the `.el' files in a directory, and ;; evaluates any `defcustom', `defgroup', or `defface' expression that @@ -91,21 +92,7 @@ ;; understand, but is in fact very easy to break. Be sure to read and ;; understand the commentary above! -;;;###autoload -(defun Custom-make-dependencies (&optional subdirs) - "Extract custom dependencies from .el files in SUBDIRS. -SUBDIRS is a list of directories. If it is nil, the command-line -arguments are used. If it is a string, only that directory is -processed. This function is especially useful in batch mode. - -Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" - (interactive "DDirectory: ") - (and (stringp subdirs) - (setq subdirs (list subdirs))) - (or subdirs - ;; Usurp the command-line-args - (setq subdirs command-line-args-left - command-line-args-left nil)) +(defun Custom-make-dependencies-1 (subdirs) (setq subdirs (mapcar #'expand-file-name subdirs)) (with-temp-buffer (let ((enable-local-eval nil) @@ -131,15 +118,21 @@ Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" (file-name-nondirectory file)))) ;; Search for defcustom/defface/defgroup ;; expressions, and evaluate them. - (ignore-errors - (while (re-search-forward - "^(defcustom\\|^(defface\\|^(defgroup" - nil t) - (beginning-of-line) - (let ((expr (read (current-buffer)))) - (eval expr) - ;; Hash the file of the affected symbol. - (setf (gethash (nth 1 expr) hash) name))))))) + (while (re-search-forward + "^(defcustom\\|^(defface\\|^(defgroup" + nil t) + (beginning-of-line) + (let ((expr (read (current-buffer)))) + ;; We need to ignore errors here, so that + ;; defcustoms with :set don't bug out. Of + ;; course, their values will not be assigned in + ;; case of errors, but their `custom-group' + ;; properties will by that time be in place, and + ;; that's all we care about. + (ignore-errors + (eval expr)) + ;; Hash the file of the affected symbol. + (setf (gethash (nth 1 expr) hash) name)))))) (cond ((zerop (hash-table-count hash)) (princ "(No customization dependencies") @@ -152,7 +145,8 @@ Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" (with-temp-file cusload-file (insert ";;; " cusload-base-file " --- automatically extracted custom dependencies\n" - "\n;;; Code:\n\n") + "\n;;; Code:\n\n" + "(autoload 'custom-add-loads \"cus-load\")\n\n") (mapatoms (lambda (sym) (let ((members (get sym 'custom-group)) @@ -167,7 +161,7 @@ Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" (if found (insert " ") (insert "(custom-add-loads '" - (symbol-name sym) " '(")) + (prin1-to-string sym) " '(")) (prin1 where (current-buffer)) (push where found))) (when found @@ -175,6 +169,31 @@ Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" (insert "\n;;; custom-load.el ends here\n")) (clrhash hash))))))))) +(defun Custom-make-one-dependency () + "Extract custom dependencies from .el files in one dir, on the command line. +Like `Custom-make-dependencies' but snarfs only one command-line argument, +making it useful in a chain of batch commands in a single XEmacs invocation." + (let ((subdir (car command-line-args-left))) + (setq command-line-args-left (cdr command-line-args-left)) + (Custom-make-dependencies-1 (list subdir)))) + +;;;###autoload +(defun Custom-make-dependencies (&optional subdirs) + "Extract custom dependencies from .el files in SUBDIRS. +SUBDIRS is a list of directories. If it is nil, the command-line +arguments are used. If it is a string, only that directory is +processed. This function is especially useful in batch mode. + +Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS" + (interactive "DDirectory: ") + (and (stringp subdirs) + (setq subdirs (list subdirs))) + (or subdirs + ;; Usurp the command-line-args + (setq subdirs command-line-args-left + command-line-args-left nil)) + (Custom-make-dependencies-1 subdirs)) + (provide 'cus-dep) ;;; cus-dep.el ends here