From 66edc569591cbcdd11b188caf9af73d9bb4e681d Mon Sep 17 00:00:00 2001 From: "Tom Breton (Tehom)" Date: Fri, 12 Nov 2010 15:24:28 -0500 Subject: [PATCH] Files and their local vars are now explored in find-action stage. --- elinstall.el | 101 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 52 deletions(-) diff --git a/elinstall.el b/elinstall.el index b06bc3a..f457bed 100644 --- a/elinstall.el +++ b/elinstall.el @@ -823,27 +823,6 @@ Returns a list whose elements are each a cons of: (expand-file-name "lisp" source-directory))) -;;;_ . elinstall-maybe-get-deffile -(defun elinstall-maybe-get-deffile (file) - "If FILE defined `generated-autoload-file', return it. -Otherwise return nil. -Return it as an absolute filename." - - (save-excursion - ;;$$FIXME load buffer if it's not already loaded - (let* - ((existing-buffer (get-file-buffer file))) - - ;; We want to get a value for generated-autoload-file from - ;; the local variables section if it's there. - ;;But if it's not loaded, we don't? Maybe should use - ;; `autoload-find-file' and load it. - (if existing-buffer - (set-buffer existing-buffer)) - (if (local-variable-p 'generated-autoload-file) - (elinstall-expand-deffile-name - generated-autoload-file) - nil)))) ;;;_ , Informational ;;;_ . elinstall-dir-has-info @@ -855,26 +834,46 @@ DIR should be an absolute path." (string-match "/info/" dir) (directory-files dir nil "\\.info\\(-[0-9]+\\)?\\(\\.gz\\)?$"))) -;;;_ . Workers -;;;_ , List of special variables used here +;;;_ , Workers +;;;_ . List of special variables used here ;;load-path-element - The relevant element of load-path ;;def-file - The file the autoload definitions etc will go into. ;;add-to-load-path-p - Controls whether to add to load-path. -;;;_ , elinstall-actions-for-source-file +;;;_ . elinstall-actions-for-source-file (defun elinstall-actions-for-source-file (filename dir) "Return a list of actions to do for FILENAME in DIR. Special variables are as noted in \"List of special variables\"." (declare (special load-path-element def-file)) - - ;;$$IMPROVE ME take and treat a "force" argument. + ;;$$IMPROVE ME add and use relevant control variables. (let* ((full-path (expand-file-name filename dir)) - ;;$$IMPROVE ME - take into account local no-byte-compile flag. + (visited (get-file-buffer full-path)) + (buf + (or + visited + ;;Visit the file cheaply. + ;;hack-local-variables can give errors. + (ignore-errors (autoload-find-file full-path)))) + ;;Figure out whether to run some actions, by file local vars. + (autoloads-p + (ignore-errors + (with-current-buffer buf + (not no-update-autoloads)))) + (def-file + (or + (ignore-errors + (with-current-buffer buf + (if (local-variable-p 'generated-autoload-file) + (elinstall-expand-deffile-name + generated-autoload-file) + nil))) + def-file)) (compile-p (and + (with-current-buffer buf (not no-byte-compile)) (featurep 'byte-compile) (string-match emacs-lisp-file-regexp filename) (file-readable-p full-path) @@ -891,21 +890,25 @@ Special variables are as noted in \"List of special variables\"." (or compile-new (y-or-n-p (concat "Compile " filename "? ")))))))) - - (list - (if compile-p - `(byte-compile ,full-path) - '()) - `(add-file-autoloads - ,def-file - ;;load-name relative to a member of load-path - ,(file-name-sans-extension - (file-relative-name - full-path - load-path-element)) - ,load-path-element - ,full-path)))) -;;;_ , elinstall-find-actions-by-spec-x + (prog1 + (list + (if compile-p + `(byte-compile ,full-path) + nil) + (if autoloads-p + `(add-file-autoloads + ,def-file + ;;load-name relative to a member of load-path + ,(file-name-sans-extension + (file-relative-name + full-path + load-path-element)) + ,load-path-element + ,full-path) + nil)) + (unless visited (kill-buffer-if-not-modified buf))))) + +;;;_ . elinstall-find-actions-by-spec-x (defun elinstall-find-actions-by-spec-x (spec dir) "Return a list of actions to do, controlled by SPEC." @@ -984,11 +987,6 @@ Special variables are as noted in \"List of special variables\"." '()) - ;;$$IMPROVE ME - ;; We want to get a value for generated-autoload-file - ;; from the local variables section if it's there. - ;;Use `elinstall-maybe-get-deffile' - ;;$$FIXME Don't do directories, but maybe recurse on ;;them, if a flag is set. @@ -1033,7 +1031,7 @@ Special variables are as noted in \"List of special variables\"." ;;$$IMPROVE ME by adding the other cases in the design. (case spec (t)))) -;;;_ , elinstall-find-actions-by-spec +;;;_ . elinstall-find-actions-by-spec (defun elinstall-find-actions-by-spec (spec load-path-element dir def-file) "" @@ -1165,10 +1163,9 @@ development." (interactive "fInstall elisp file: ") (let ((def-file-name - (or - (elinstall-maybe-get-deffile file) - (elinstall-expand-deffile-name - generated-autoload-file)))) + ;;This is the default. File local vars can override it. + (elinstall-expand-deffile-name + generated-autoload-file))) (elinstall-x file `(def-file ,def-file-name (nil) (file ,file))))) -- 2.11.4.GIT