1 ;;;_ elinstall.el --- Automatically and flexibly install elisp files
5 ;; Copyright (C) 2010 Tom Breton (Tehom)
7 ;; Author: Tom Breton (Tehom) <tehom@panix.com>
8 ;; Keywords: maint, tools, internal
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;; elinstall Use this for overall loading
30 ;; elinstall-arrange-preload - Use this for non-autogenerated
31 ;; files that need to be linked in.
33 ;; elinstall-update-directory-autoloads
34 ;; elinstall-update-file-autoloads
40 (require 'cus-edit
) ;;Because we save "installedness" manually
41 (require 'byte-compile nil t
) ;;
49 "Customizations for elinstall"
51 ;;;_ . elinstall-default-priority
52 (defcustom elinstall-default-priority
54 "Default priority for site-start"
57 ;;;_ . elinstall-default-preload-target
58 (defcustom elinstall-default-preload-target
59 "~/.emacs.d/site-start.d/"
60 "Default preload-target for registering autoloads"
64 (const "~/.emacs.d/site-start.d/")
65 (const "/etc/emacs/site-start.d/")
69 ;;;_ . elinstall-already-installed
70 (defvar elinstall-already-installed
72 "(AUTOMATIC) Things that have already been installed.
73 This exists for recording what has been installed.
75 Though it's saved as customizable, user interaction is not
78 ;;;_ . elinstall-stages
79 (defstruct (elinstall-stages
80 (:constructor elinstall-make-stages
)
81 (:conc-name elinstall-stages-
>)
83 "The elinstall stages"
89 ;;;_ . Regular expressions
90 ;;;_ , elinstall-elisp-regexp
91 (defconst elinstall-elisp-regexp
94 (suf (get-load-suffixes))
95 (unless (string-match "\\.elc" suf
) (push suf tmp
)))
96 (concat "^[^=.].*" (regexp-opt tmp t
) "\\'"))
97 "Regular expression that matches elisp files" )
99 ;;;_ . elinstall-directory-true-name
100 (defun elinstall-directory-true-name ()
101 "Get the true name of the directory the calling code lives in.
102 CAUTION: This is sensitive to where it's called. That's the point of it."
105 (file-truename load-file-name
)
106 (file-truename buffer-file-name
))))
107 ;;;_ . Checking installedness
108 ;;;_ , elinstall-already-installed
109 (defun elinstall-already-installed (project-name)
110 "Return non-nil if PROJECT-NAME has been installed."
111 (member project-name elinstall-already-installed
))
113 ;;;_ , elinstall-record-installed
114 (defun elinstall-record-installed (project-name)
115 "Record that PROJECT-NAME has been installed."
117 (add-to-list 'elinstall-already-installed project-name
)
118 (customize-save-variable
119 'elinstall-already-installed
120 elinstall-already-installed
121 "Set by elinstall-record-installed"))
122 ;;;_ . Finding deffiles
123 ;;;_ , elinstall-expand-deffile-name
124 (defun elinstall-expand-deffile-name (deffile)
125 "Expand DEFFILE autoload.el's way."
127 (expand-file-name (or deffile
"loaddefs.el")
128 (expand-file-name "lisp"
134 ;;;_ , Doing autoload actions (adapted from autoload.el)
135 ;;;_ . Utilities about the action list
136 ;;;_ , elinstall-remove-autogen-action
137 (defun elinstall-remove-autogen-action (file actions
)
138 "Return ACTIONS minus any add-file-autoloads on FILE removed."
145 (if (equal file
(third act
))
150 ;;;_ , elinstall-get-autogen-action
151 (defun elinstall-get-autogen-action (file actions
)
155 (dolist (act actions
)
158 (when (equal file
(third act
))
159 (setq the-act act
)))))
161 ;;;_ . About printing to autoload file
162 ;;;_ , elinstall-insert-section-header
163 (defun elinstall-insert-section-header (outbuf form
)
164 "Insert the section-header line,
165 which lists the file name and which functions are in it, etc."
166 (insert generate-autoload-section-header
)
169 ;; Break that line at spaces, to avoid very long lines.
170 ;; Make each sub-line into a comment.
171 (with-current-buffer outbuf
176 (skip-chars-forward "^ \n")
178 (insert "\n" generate-autoload-section-continuation
))))))
180 ;;;_ , elinstall-insert-autoload-section
181 (defun elinstall-insert-autoload-section (text form
&optional comment-string
)
182 "Insert TEXT into current buffer as an autoload section"
184 (let* ( ;; This does something in Lucid Emacs.
187 (float-output-format nil
))
189 (elinstall-insert-section-header (current-buffer) form
)
191 (insert ";;; " comment-string
"\n"))
193 (insert generate-autoload-section-trailer
)))
195 ;;;_ . Making autoloads
196 ;;;_ , elinstall-make-autoload-action
197 (defun elinstall-make-autoload-action (buf def-file load-path-element full-path
)
198 "Return the autoloads for current buffer as a string"
200 ;;We put all the text into a temp buffer, then get that buffer's
204 (generate-new-buffer " *temp*"))
207 (file-name-nondirectory full-path
))
209 ;; Apparently this does something in Lucid Emacs.
212 (float-output-format nil
)
214 ;;load-name relative to a member of load-path.
216 (file-name-sans-extension
219 load-path-element
))))
221 (with-current-buffer buf
226 (goto-char (point-min))
227 (message "Finding autoloads for %s..." short-name
)
229 (skip-chars-forward " \t\n\f")
231 ((looking-at (regexp-quote generate-autoload-cookie
))
232 (search-forward generate-autoload-cookie
)
233 (skip-chars-forward " \t")
236 ;; Read the next form and make an autoload.
237 (let* ((form (prog1 (read (current-buffer))
238 (or (bolp) (forward-line 1))))
240 (make-autoload form relative-name
)))
242 (push (nth 1 form
) autoloads-done
)
243 (setq autoload form
))
244 (let ((autoload-print-form-outbuf outbuf
))
245 (autoload-print-form autoload
)))
247 ;; Copy the rest of the line to the output.
248 (princ (buffer-substring
250 ;; Back up over whitespace,
252 (skip-chars-backward " \f\t")
253 (if (= (char-after (1+ (point))) ?
)
257 (progn (forward-line 1) (point)))
260 ;; Don't read the comment.
265 (message "Finding autoloads for %s...done" short-name
))
267 ;;Return this action. The temp buffer's contents is
273 ,(with-current-buffer outbuf
(buffer-string))
276 ;;This in unwind-protected
277 (when (buffer-live-p outbuf
) (kill-buffer outbuf
))))))
280 ;;;_ , elinstall-generate-file-autoloads
282 (defun elinstall-generate-file-autoloads
283 (relative-name full-name text autoloads-done
)
284 "Insert at point a loaddefs autoload section for FILE.
285 Autoloads are generated for defuns and defmacros in FILE
286 marked by `generate-autoload-cookie' (which see).
287 If FILE is being visited in a buffer, the contents of the buffer
289 Return non-nil in the case where no autoloads were added at point.
291 FULL-NAME is the absolute name of the file.
292 RELATIVE-NAME is its name respective to some component of load-path."
293 (if (not (equal text
""))
294 ;; Insert the section-header line which lists the file name and
295 ;; which functions are in it, etc.
296 (elinstall-insert-autoload-section
301 (autoload-trim-file-name full-name
)
302 (nth 5 (file-attributes full-name
)))
304 "Generated autoloads from "
305 (autoload-trim-file-name full-name
)))
308 ;;;_ , elinstall-deffile-insert-autoloads
309 (defun elinstall-deffile-insert-autoloads (file args
)
310 "Update the autoloads for FILE in current buffer.
311 Return FILE if there was no autoload cookie in it, else nil.
313 Current buffer must be a loaddef-style file.
315 LOAD-NAME is the absolute name of the file.
316 RELATIVE-NAME is its name respective to some component of load-path."
324 (goto-char (point-min))
325 ;; Look for the section for FILE
326 (while (and (not found
)
327 (search-forward generate-autoload-section-header nil t
))
328 (let ((form (autoload-read-section-header)))
330 ((equal (nth 2 form
) file
)
331 ;; We found the section for this file.
332 (let ((begin (match-beginning 0)))
334 (search-forward generate-autoload-section-trailer
)
335 (delete-region begin
(point))
337 ((string< file
(nth 2 form
))
338 ;; We've come to a section alphabetically later than
339 ;; FILE. We assume the file is in order and so
340 ;; there must be no section for FILE. We will
341 ;; insert one before the section here.
342 (goto-char (match-beginning 0))
343 (setq found
'new
)))))
347 ;; No later sections in the file. Put before the last page.
348 (goto-char (point-max))
349 (search-backward "\f" nil t
)))
351 (apply #'elinstall-generate-file-autoloads
354 (if no-autoloads file nil
)))
355 ;;;_ . Arranging to add to info-path and load-path
356 ;;;_ , elinstall-generate-add-to-path
357 (defun elinstall-generate-add-to-path (path-element type
)
358 "Insert code at point to add PATH-ELEMENT to a path.
360 * `add-to-load-path', add to load-path
361 * `add-to-info-path', add to Info-additional-directory-list
363 Current buffer must be a loaddef-style file."
366 (add-to-load-path 'load-path
)
367 (add-to-info-path 'Info-additional-directory-list
)
368 (t (error "Type not recognized"))))
371 (add-to-load-path "load-path")
372 (add-to-info-path "info-path")))
375 (print-readably t
) ; This does something in Lucid Emacs.
376 (float-output-format nil
))
378 (message "Generating %s additions..." description
)
380 (elinstall-insert-autoload-section
382 `(add-to-list ',path-symbol
384 ,(file-relative-name path-element
)
387 (file-truename load-file-name
))))))
388 (list type
(list path-element
) nil nil nil
)
390 (message "Generating %s additions...done" description
)))
393 ;;;_ , elinstall-deffile-insert-add-to-path
394 (defun elinstall-deffile-insert-add-to-path (path-element type
)
395 "Insert code in current buffer to add PATH-ELEMENT to a path.
397 * `add-to-load-path', add to load-path
398 * `add-to-info-path', add to Info-default-directory-list
400 Current buffer must be a loaddef-style file."
408 (goto-char (point-min))
409 ;; Look for the section for PATH-ELEMENT
410 (while (and (not found
)
411 (search-forward generate-autoload-section-header nil t
))
412 (let ((form (autoload-read-section-header)))
415 (equal (nth 0 form
) type
)
416 (member path-element
(nth 1 form
)))
418 ;; We found the section for this add.
419 (let ((begin (match-beginning 0)))
421 (search-forward generate-autoload-section-trailer
)
422 (delete-region begin
(point))
428 ;; No later sections in the file. Put before the last page.
429 (goto-char (point-max))
430 (search-backward "\f" nil t
)))
432 (elinstall-generate-add-to-path path-element type
)))
434 ;;This never belongs in the no-autoloads section.
436 ;;;_ . elinstall-deffile-insert
438 (defun elinstall-deffile-insert (action)
439 "Insert autoloads etc into current file according to ACTION.
440 The format of ACTION is described in the design docs.
442 Return filename if this action belongs in the no-autoload section."
447 (elinstall-deffile-insert-autoloads
452 (elinstall-deffile-insert-add-to-path
458 (elinstall-deffile-insert-add-to-path
463 ((preload-file run-tests byte-compile
)
464 (error "This case should not come here.")))))
466 ;;;_ . elinstall-prepare-deffile
467 (defun elinstall-prepare-deffile (deffile)
468 "Try to ensure that DEFFILE is available for receiving autoloads"
470 (autoload-ensure-default-file deffile
)
471 (with-current-buffer (find-file-noselect deffile
)
474 ;; We must read/write the file without any code conversion,
475 ;; but still decode EOLs.
476 (let ((coding-system-for-read 'raw-text
))
478 ;; This is to make generated-autoload-file have Unix EOLs, so
479 ;; that it is portable to all platforms.
480 (setq buffer-file-coding-system
'raw-text-unix
))
481 (or (> (buffer-size) 0)
482 (error "Autoloads file %s does not exist" buffer-file-name
))
483 (or (file-writable-p buffer-file-name
)
484 (error "Autoloads file %s is not writable"
487 ;;;_ . elinstall-update-deffile
489 ;;Adapted from autoload.el `update-directory-autoloads'.
491 (defun elinstall-update-deffile (target actions
&optional
494 Update file TARGET with current autoloads as specified by ACTIONS.
495 Also remove any old definitions pointing to libraries that can no
498 ACTIONS must be a list of actions (See the format doc). Each one's
499 filename must be relative to some element of load-path.
501 USE-LOAD-PATH is a list to use as load-path. It should include
502 any new load-path that we are arranging to create. If it's not given,
503 load-path itself is used.
505 If FORCE is `t', do it regardless of timestamps etc. (Not implemented)
506 Other non-nil cases of FORCE are reserved for future development.
508 This uses `update-file-autoloads' (which see) to do its work.
509 In an interactive call, you must give one argument, the name
510 of a single directory."
513 (use-load-path (or use-load-path load-path
))
514 (this-time (current-time))
515 ;;files with no autoload cookies.
518 (elinstall-prepare-deffile target
)
520 (find-file-noselect target
)
523 (elinstall-remove-autogen-action
524 (autoload-trim-file-name target
)
527 (goto-char (point-min))
528 (while (search-forward generate-autoload-section-header nil t
)
529 (let* ((form (autoload-read-section-header))
531 (cond ((and (consp file
) (stringp (car file
)))
532 ;; This is a list of files that have no
534 ;; There shouldn't be more than one such entry.
535 ;; Remove the obsolete section.
536 (autoload-remove-section (match-beginning 0))
537 (let ((last-time (nth 4 form
)))
539 (let ((file-time (nth 5 (file-attributes file
))))
541 (not (time-less-p last-time file-time
)))
543 (push file no-autoloads
)
545 (elinstall-remove-autogen-action
547 ((not (stringp file
)))
551 (locate-library file nil use-load-path
)))
553 ;;File doesn't exist, so remove its
556 (autoload-remove-section
557 (match-beginning 0)))
559 ;; File hasn't changed, so do nothing.
562 (nth 5 (file-attributes file-path
)))
565 (elinstall-deffile-insert
566 (elinstall-get-autogen-action
570 (elinstall-remove-autogen-action
573 ;; Remaining actions have no existing autoload sections yet.
576 (delq nil
(mapcar #'elinstall-deffile-insert actions
))))
578 ;; Sort them for better readability.
579 (setq no-autoloads
(sort no-autoloads
'string
<))
580 ;; Add the `no-autoloads' section.
581 (goto-char (point-max))
582 (search-backward "\f" nil t
)
583 (elinstall-insert-autoload-section
585 (list 'autoloads nil nil no-autoloads this-time
)))
588 ;;;_ . elinstall-stage-update-deffiles
589 (defun elinstall-stage-update-deffiles (segment-list force use-load-path
)
590 "Update any deffiles mentioned in SEGMENT-LIST.
591 FORCE and USE-LOAD-PATH have the same meaning as in
592 `elinstall-update-deffile'.
597 ((deffile (car segment
)))
598 (if (stringp deffile
)
599 (elinstall-update-deffile deffile
(cdr segment
) force
603 ;;;_ , Doing actions to arrange preloads
604 ;;;_ . elinstall-symlink-on-emacs-start
605 (defun elinstall-symlink-on-emacs-start
606 (filename target-basename target-dir
&optional priority force
)
607 "Symlink to TARGET-BASENAME.el in TARGET-DIR
609 If PRIORITY is given, it will be used as the priority prefix,
610 otherwise elinstall-default-priority will be.
611 PRIORITY must be an integer or nil.
612 If FORCE is `t', do it regardless of timestamps etc.
613 Other non-nil cases of FORCE are reserved for future development."
616 (priority (or priority elinstall-default-priority
))
623 (expand-file-name target-name-nodir target-dir
)))
627 ;;Path should already exist.
629 (file-exists-p target-dir
))
630 (message "The target directory doesn't exist."))
631 ;;Target shouldn't already exist, but if force is given, let
633 ;;$$IMPROVE ME If it is a symlink pointing to the same place,
634 ;;do nothing even on force.
636 (file-exists-p target
)
641 (format "Really overwrite %s? " target
))))
642 (message "File %s already exists" target
)))
650 ;;;_ . elinstall-add-to-dot-emacs
651 (defun elinstall-add-to-dot-emacs (dot-emacs-name filename force
&rest r
)
652 "Add code to load FILENAME to .emacs.
653 FILENAME should not have an extension"
656 (with-current-buffer (find-file-noselect dot-emacs-name
)
659 (goto-char (point-max))
660 (insert "\n;;Added by elinstall")
661 (insert "\n;;Consider using my-site-start to manage .emacs\n")
662 (pp `(load ,filename
) (current-buffer))
666 ;;;_ . elinstall-arrange-preload
668 (defun elinstall-arrange-preload (force filename basename
&optional priority
)
669 "Arrange for FILENAME to be loaded on emacs start.
670 FORCE has its usual meaning.
671 BASENAME and PRIORITY are used as arguments to
672 `elinstall-symlink-on-emacs-start'.
676 ((preload-target elinstall-default-preload-target
))
678 ;;Dispatch the possibilities.
680 ((eq preload-target
'dot-emacs
)
681 (elinstall-add-to-dot-emacs "~/.emacs" filename force
))
682 ((stringp preload-target
)
683 (elinstall-symlink-on-emacs-start
684 filename basename preload-target priority force
))
685 ((null preload-target
)
686 (message "Not arranging for preloads"))
688 (message "I don't recognize that")))))
689 ;;;_ . elinstall-stage-arrange-preloads
690 (defun elinstall-stage-arrange-preloads (actions deffiles-used force
)
691 "Arrange any preloads mentioned in ACTIONS."
705 (member filename deffiles-used
)))))
709 #'elinstall-arrange-preload
714 "elinstall-stage-arrange-preloads: Action not
720 ;;;_ . elinstall-stage-run-tests
721 (defun elinstall-stage-run-tests (actions)
722 "Run any tests mentioned in ACTIONS."
728 ;;$$WRITE ME - not a high priority right now.
732 "elinstall-stage-run-tests: Action not
738 ;;;_ . elinstall-stage-byte-compile
739 (defun elinstall-stage-byte-compile (actions)
740 "Do any byte-compilation mentioned in ACTIONS."
745 ;;$$IMPROVE ME Understand flags to control second
746 ;;argument (whether to load file after
749 (byte-compile-file (second act
)))
752 "elinstall-stage-byte-compile: Action not
755 ;;;_ . Segregating actions
756 ;;;_ , elinstall-remove-empty-segs
757 (defun elinstall-remove-empty-segs (segment-list)
758 "Return SEGMENT-LIST minus any segments that have no actions.
759 Intended only for the deffile stage data."
768 ;;;_ , elinstall-segregate-actions
769 (defun elinstall-segregate-actions (actions)
770 "Return actions segregated by deffile.
772 Returns a list whose elements are each a cons of:
773 * deffile filename or nil
774 * A list of actions to be done for that deffile."
781 (arrange-preloads '()))
783 (dolist (act actions
)
790 ((deffile-name (second act
))
792 (assoc deffile-name build-deffiles
)))
794 ;;There are already actions on this deffile.
795 ;;Splice this action in.
797 (cons act
(cdr cell-already
)))
798 ;;There are no actions on this deffile. Add a
799 ;;place for them and include this action.
800 (push (list deffile-name act
) build-deffiles
))))
802 (push act arrange-preloads
))
804 (push act run-tests
))
806 (push act byte-compile
)))))
808 (elinstall-make-stages
810 (elinstall-remove-empty-segs build-deffiles
)
817 ;;;_ . Finding actions
819 ;;;_ . elinstall-dir-has-info
821 ;;$$IMPROVE ME - Can this test be made more precise?
822 (defun elinstall-dir-has-info (dir)
823 "Return non-nil if DIR has info files in it.
824 DIR should be an absolute path."
826 (string-match "/info/" dir
)
827 (directory-files dir nil
"\\.info\\(-[0-9]+\\)?\\(\\.gz\\)?$")))
830 ;;;_ . List of special variables used in this section
831 ;;load-path-element - The relevant element of load-path
832 ;;def-file - The file the autoload definitions etc will go into.
833 ;;add-to-load-path-p - Controls whether to add to load-path.
834 ;;recurse-dirs-p - Whether to recurse into subdirectories.
835 (defconst elinstall-find-actions-control-vars
836 '(add-to-load-path-p recurse-dirs-p
)
837 "Control special variables that the find-actions tree recognizes" )
838 ;;;_ . elinstall-actions-for-source-file
839 (defun elinstall-actions-for-source-file (filename dir
)
840 "Return a list of actions to do for FILENAME in DIR.
841 Special variables are as noted in \"List of special variables\"."
843 load-path-element def-file
))
846 (expand-file-name filename dir
)))
849 (file-readable-p full-path
)
850 (not (auto-save-file-name-p full-path
)))
851 ;;$$IMPROVE ME create and use relevant control variables.
854 (visited (get-file-buffer full-path
))
858 ;;Visit the file cheaply.
859 ;;hack-local-variables can give errors.
860 (ignore-errors (autoload-find-file full-path
))))
864 (with-current-buffer buf
865 (if (local-variable-p 'generated-autoload-file
)
866 (elinstall-expand-deffile-name
867 generated-autoload-file
)
870 ;;Figure out whether to run some actions, by file local vars.
873 (with-current-buffer buf
874 (not no-update-autoloads
))))
877 (featurep 'byte-compile
)
878 (string-match emacs-lisp-file-regexp filename
)
880 (with-current-buffer buf
881 (not no-byte-compile
)))
883 ((dest (byte-compile-dest-file full-path
))
884 ;;$$PUNT - currently, we wouldn't have
885 ;;gotten here if we weren't intending to do
886 ;;everything so set force variables accordingly.
889 (if (file-exists-p dest
)
890 ;; File was already compiled.
891 (or recompile-p
(file-newer-than-file-p full-path dest
))
893 (y-or-n-p (concat "Compile " filename
"? "))))))))
898 `(byte-compile ,full-path
)
901 (elinstall-make-autoload-action
902 buf def-file load-path-element full-path
)
904 (unless visited
(kill-buffer-if-not-modified buf
)))))))
905 ;;;_ . elinstall-actions-for-dir
906 (defun elinstall-actions-for-dir (dirname &optional recurse-dirs-p
)
907 "Make actions for DIR.
908 Recurse just if RECURSE-DIRS-P"
910 load-path-element def-file add-to-load-path-p
))
911 ;;This does not treat symlinks specially. $$IMPROVE ME it could
912 ;;treat/not treat them conditional on control variables.
915 ;;Relative filenames of the source files. We know our
916 ;;loaddefs.el isn't really source so remove it. We'd have
917 ;;removed it anyways after seeing file local vars.
924 elinstall-elisp-regexp
)))
925 ;;Absolute filenames of subdirectories.
926 ;;Don't accept any directories beginning with dot. If user
927 ;;really wants to explore one he can use `(dir ".NAME")'.
934 (file-directory-p filename
)
944 elisp-source-files
;;If list is not empty.
952 ;;Sometimes arrange to add this directory to load-path.
959 ;;$$IMPROVE ME - be controlled by a control variable.
960 ;;Sometimes add this directory to info path.
962 (elinstall-dir-has-info dirname
)
971 (elinstall-actions-for-source-file
980 (elinstall-find-actions-by-spec-x
988 ;;;_ . elinstall-find-actions-by-spec-x
990 (defun elinstall-find-actions-by-spec-x (spec dir
)
991 "Return a list of actions to do, controlled by SPEC."
993 load-path-element def-file add-to-load-path-p
1006 (elinstall-find-actions-by-spec-x
1014 #'(lambda (sub-spec)
1015 (elinstall-find-actions-by-spec-x
1020 ;;(matching PATTERN SPEC)
1024 (elinstall-find-actions-by-spec-x
1028 dir t
(second spec
))))
1032 (elinstall-actions-for-source-file
1035 ;;Rather than trying to bind all control variables each time
1036 ;;thru, we use `set' and `unwind-protect'.
1038 ;;control TYPE DISPOSITION SPEC
1040 ((key (second spec
))
1042 (if (memq key elinstall-find-actions-control-vars
)
1045 (set old-value
(symbol-value key
))
1046 (set key
(third spec
))
1047 (elinstall-find-actions-by-spec-x
1050 (set key old-value
))
1051 (error "Unrecognized control variable %s" key
))))
1056 (elinstall-actions-for-dir
1066 `((add-to-load-path ,def-file
,dir
))
1068 ((load-path-element dir
))
1069 (elinstall-find-actions-by-spec-x
1075 ;;(def-file FN ARGS SPEC)
1081 (for-preload (third spec
)))
1082 (assert (listp for-preload
))
1086 (and for-preload
(car for-preload
))
1090 ,@(cdr for-preload
))
1093 (elinstall-find-actions-by-spec-x
1094 (fourth spec
) dir
)))))
1100 (elinstall-actions-for-dir dir nil
))
1102 (elinstall-actions-for-dir dir t
)))))
1104 ;;;_ . elinstall-find-actions-by-spec
1105 (defun elinstall-find-actions-by-spec (spec load-path-element dir def-file
)
1109 ((load-path-element load-path-element
)
1111 (add-to-load-path-p t
)
1114 load-path-element def-file add-to-load-path-p
1117 (elinstall-find-actions-by-spec-x
1120 ;;;_ . high-level work
1121 ;;;_ , elinstall-get-relevant-load-path
1122 (defun elinstall-get-relevant-load-path (actions)
1132 ;;;_ , elinstall-get-deffile-list
1133 (defun elinstall-get-deffile-list (stages)
1134 "Get a list of deffile names"
1138 (elinstall-stages->build-deffiles stages
)))
1141 (defun elinstall-x (dir spec
&optional force
)
1145 ;;This is just the default deffile, spec can override it.
1147 (elinstall-expand-deffile-name nil
))
1149 (elinstall-find-actions-by-spec
1154 (stages (elinstall-segregate-actions actions
))
1156 (elinstall-get-relevant-load-path
1159 (elinstall-stage-update-deffiles
1160 (elinstall-stages->build-deffiles stages
)
1163 (elinstall-stage-arrange-preloads
1164 (elinstall-stages->arrange-preloads stages
)
1165 (elinstall-get-deffile-list stages
)
1167 (elinstall-stage-byte-compile
1168 (elinstall-stages->byte-compile stages
))
1173 (defun elinstall (project-name path spec
&optional force
)
1174 "Install elisp files.
1175 They need not be a formal package.
1179 PROJECT-NAME - the name of the project
1181 PATH - Path to the project.
1182 Suggestion: (elinstall-directory-true-name)
1184 SPEC - a spec for the autoloads etc to make. It can be as simple as
1185 \(dir \"\.\") for installing one directory.
1187 If FORCE is t, install a package even if it has already been
1188 installed. Other non-nil cases of FORCE are reserved for future
1195 (not (elinstall-already-installed project-name
)))
1196 (yes-or-no-p (format "Re-install %s? " project-name
)))
1199 `(def-file "loaddefs.el" (if-used ,project-name
) ,spec
)
1201 (elinstall-record-installed project-name
)))
1205 ;;;_ . elinstall-update-directory-autoloads
1206 ;;$$SPLIT ME - one to just classically update autoloads, one to
1210 (defun elinstall-update-directory-autoloads (dir)
1213 (interactive "DInstall all elisp files from directory: ")
1218 (elinstall-expand-deffile-name
1219 generated-autoload-file
)))
1223 `(def-file ,def-file-name
(nil) (dir ".")))))
1227 ;;;_ . elinstall-update-file-autoloads
1228 ;;$$SPLIT ME - one to just classically update autoloads, one to
1232 (defun elinstall-update-file-autoloads (file)
1235 (interactive "fInstall elisp file: ")
1238 ;;This is the default. File local vars can override it.
1239 (elinstall-expand-deffile-name
1240 generated-autoload-file
)))
1243 `(def-file ,def-file-name
(nil) (file ,file
)))))
1247 (provide 'elinstall
)
1249 ;;;_ * Local emacs vars.
1250 ;;;_ + Local variables:
1255 ;;; elinstall.el ends here