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/")
70 ;;;_ . elinstall-already-installed
71 (defcustom elinstall-already-installed
73 "(AUTOMATIC) Things that have already been installed.
74 This exists for recording what has been installed. User interaction is not
75 contemplated at this time." )
77 ;;;_ . elinstall-stages
78 (defstruct (elinstall-stages
79 (:constructor elinstall-make-stages
)
80 (:conc-name elinstall-stages-
>)
82 "The elinstall stages"
88 ;;;_ . Regular expressions
89 ;;;_ , elinstall-elisp-regexp
90 (defconst elinstall-elisp-regexp
93 (suf (get-load-suffixes))
94 (unless (string-match "\\.elc" suf
) (push suf tmp
)))
95 (concat "^[^=.].*" (regexp-opt tmp t
) "\\'"))
96 "Regular expression that matches elisp files" )
98 ;;;_ . elinstall-directory-true-name
99 (defun elinstall-directory-true-name ()
100 "Get the true name of the directory the calling code lives in.
101 CAUTION: This is sensitive to where it's called. That's the point of it."
104 (file-truename load-file-name
)
105 (file-truename buffer-file-name
))))
106 ;;;_ . Checking installedness
107 ;;;_ , elinstall-already-installed
108 (defun elinstall-already-installed (project-name)
109 "Return non-nil if PROJECT-NAME has been installed."
110 (member project-name elinstall-already-installed
))
112 ;;;_ , elinstall-record-installed
113 (defun elinstall-record-installed (project-name)
114 "Record that PROJECT-NAME has been installed."
116 (add-to-list 'elinstall-already-installed project-name
)
117 (customize-save-variable
118 'elinstall-already-installed
119 elinstall-already-installed
120 "Set by elinstall-record-installed"))
124 ;;;_ , Doing autoload actions (adapted from autoload.el)
125 ;;;_ . Utilities about the action list
126 ;;;_ , elinstall-remove-autogen-action
127 (defun elinstall-remove-autogen-action (file actions
)
128 "Return ACTIONS minus any add-file-autoloads on FILE removed."
135 (if (equal file
(third act
))
140 ;;;_ , elinstall-get-autogen-action
141 (defun elinstall-get-autogen-action (file actions
)
145 (dolist (act actions
)
148 (when (equal file
(third act
))
149 (setq the-act act
)))))
151 ;;;_ . elinstall-insert-section-header
152 (defun elinstall-insert-section-header (outbuf form
)
153 "Insert the section-header line,
154 which lists the file name and which functions are in it, etc."
155 (insert generate-autoload-section-header
)
158 ;; Break that line at spaces, to avoid very long lines.
159 ;; Make each sub-line into a comment.
160 (with-current-buffer outbuf
165 (skip-chars-forward "^ \n")
167 (insert "\n" generate-autoload-section-continuation
))))))
169 ;;;_ . Making autoloads
170 ;;;_ , elinstall-generate-file-autoloads
171 ;;override to allow slashed load-paths
172 ;;Quick and dirty: We just adapt `generate-file-autoloads' and add
174 ;;`relative-to' can be:
175 ;; * nil: act as at present. Assume that FILE's immediate directory
177 ;; * t :: use default-directory
178 ;; * a string :: relative to it, as a filename
180 (defun elinstall-generate-file-autoloads (relative-name full-name
)
181 "Insert at point a loaddefs autoload section for FILE.
182 Autoloads are generated for defuns and defmacros in FILE
183 marked by `generate-autoload-cookie' (which see).
184 If FILE is being visited in a buffer, the contents of the buffer
186 Return non-nil in the case where no autoloads were added at point.
188 FULL-NAME is the absolute name of the file.
189 RELATIVE-NAME is its name respective to some component of load-path."
190 (let* ((outbuf (current-buffer))
193 (print-readably t
) ; This does something in Lucid Emacs.
194 (float-output-format nil
)
196 (visited (get-file-buffer full-name
))
199 ;; It is faster to avoid visiting the file.
200 (ignore-errors (autoload-find-file full-name
))))
203 (with-current-buffer source-buf
204 ;;$$MOVE ME - this should be checked in action-finding.
205 ;; Obey the no-update-autoloads file local variable.
206 (unless no-update-autoloads
207 (message "Generating autoloads for %s..." relative-name
)
208 (setq output-start
(with-current-buffer outbuf
(point)))
212 (goto-char (point-min))
214 (skip-chars-forward " \t\n\f")
216 ((looking-at (regexp-quote generate-autoload-cookie
))
217 (search-forward generate-autoload-cookie
)
218 (skip-chars-forward " \t")
221 ;; Read the next form and make an autoload.
222 (let* ((form (prog1 (read (current-buffer))
223 (or (bolp) (forward-line 1))))
225 (make-autoload form relative-name
)))
227 (push (nth 1 form
) autoloads-done
)
228 (setq autoload form
))
229 (let ((autoload-print-form-outbuf outbuf
))
230 (autoload-print-form autoload
)))
232 ;; Copy the rest of the line to the output.
233 (princ (buffer-substring
235 ;; Back up over whitespace, to preserve it.
236 (skip-chars-backward " \f\t")
237 (if (= (char-after (1+ (point))) ?
)
241 (progn (forward-line 1) (point)))
244 ;; Don't read the comment.
248 (forward-line 1))))))
251 (with-current-buffer outbuf
253 ;; Insert the section-header line which lists the file name
254 ;; and which functions are in it, etc.
255 (goto-char output-start
)
256 (elinstall-insert-section-header
261 (autoload-trim-file-name full-name
)
262 (nth 5 (file-attributes full-name
))))
264 (insert ";;; Generated autoloads from "
265 (autoload-trim-file-name full-name
) "\n"))
266 (insert generate-autoload-section-trailer
)))
267 (message "Generating autoloads for %s...done" relative-name
))
270 ;; We created this buffer, so we should kill it.
271 (kill-buffer (current-buffer))))
272 (message "Could not load %s" relative-name
))
277 ;;;_ , elinstall-deffile-insert-autoloads
278 (defun elinstall-deffile-insert-autoloads (file load-name
)
279 "Update the autoloads for FILE in current buffer.
280 Return FILE if there was no autoload cookie in it, else nil.
282 Current buffer must be a loaddef-style file.
284 LOAD-NAME is the absolute name of the file.
285 RELATIVE-NAME is its name respective to some component of load-path."
293 (goto-char (point-min))
294 ;; Look for the section for FILE
295 (while (and (not found
)
296 (search-forward generate-autoload-section-header nil t
))
297 (let ((form (autoload-read-section-header)))
299 ((equal (nth 2 form
) file
)
300 ;; We found the section for this file.
301 (let ((begin (match-beginning 0)))
303 (search-forward generate-autoload-section-trailer
)
304 (delete-region begin
(point))
306 ((string< file
(nth 2 form
))
307 ;; We've come to a section alphabetically later than
308 ;; FILE. We assume the file is in order and so
309 ;; there must be no section for FILE. We will
310 ;; insert one before the section here.
311 (goto-char (match-beginning 0))
312 (setq found
'new
)))))
316 ;; No later sections in the file. Put before the last page.
317 (goto-char (point-max))
318 (search-backward "\f" nil t
)))
320 (elinstall-generate-file-autoloads file load-name
))))
322 (if no-autoloads file nil
)))
323 ;;;_ . Arranging to add to info-path and load-path
324 ;;;_ , elinstall-generate-add-to-path
325 (defun elinstall-generate-add-to-path (path-element type
)
326 "Insert code at point to add PATH-ELEMENT to a path.
328 * `add-to-load-path', add to load-path
329 * `add-to-info-path', add to Info-default-directory-list
331 Current buffer must be a loaddef-style file."
334 (add-to-load-path 'load-path
)
335 (add-to-info-path 'Info-default-directory-list
)
336 (t (error "Type not recognized"))))
339 (add-to-load-path "load-path")
340 (add-to-info-path "info-path")))
343 (print-readably t
) ; This does something in Lucid Emacs.
344 (float-output-format nil
))
346 (message "Generating %s additions..." description
)
349 (elinstall-insert-section-header
351 (list type
(list path-element
) nil nil nil
))
353 (insert ";;; Generated path addition\n")
355 `(add-to-list ',path-symbol
357 ,(file-relative-name path-element
)
360 (file-truename load-file-name
)))))
363 (insert generate-autoload-section-trailer
)
364 (message "Generating %s additions...done" description
)))
367 ;;;_ , elinstall-deffile-insert-add-to-path
368 (defun elinstall-deffile-insert-add-to-path (path-element type
)
369 "Insert code in current buffer to add PATH-ELEMENT to a path.
371 * `add-to-load-path', add to load-path
372 * `add-to-info-path', add to Info-default-directory-list
374 Current buffer must be a loaddef-style file."
382 (goto-char (point-min))
383 ;; Look for the section for PATH-ELEMENT
384 (while (and (not found
)
385 (search-forward generate-autoload-section-header nil t
))
386 (let ((form (autoload-read-section-header)))
389 (equal (nth 0 form
) type
)
390 (member path-element
(nth 1 form
)))
392 ;; We found the section for this add.
393 (let ((begin (match-beginning 0)))
395 (search-forward generate-autoload-section-trailer
)
396 (delete-region begin
(point))
402 ;; No later sections in the file. Put before the last page.
403 (goto-char (point-max))
404 (search-backward "\f" nil t
)))
406 (elinstall-generate-add-to-path path-element type
)))
408 ;;This never belongs in the no-autoloads section.
410 ;;;_ . elinstall-deffile-insert
412 (defun elinstall-deffile-insert (action)
413 "Insert autoloads etc into current file according to ACTION.
414 The format of ACTION is described in the design docs.
416 Return filename if this action belongs in the no-autoload section."
421 (elinstall-deffile-insert-autoloads
426 (elinstall-deffile-insert-add-to-path
432 (elinstall-deffile-insert-add-to-path
437 ((preload-file run-tests byte-compile
)
438 (error "This case should not come here.")))))
440 ;;;_ . elinstall-prepare-deffile
441 (defun elinstall-prepare-deffile (deffile)
442 "Try to ensure that DEFFILE is available for receiving autoloads"
444 (autoload-ensure-default-file deffile
)
445 (with-current-buffer (find-file-noselect deffile
)
448 ;; We must read/write the file without any code conversion,
449 ;; but still decode EOLs.
450 (let ((coding-system-for-read 'raw-text
))
452 ;; This is to make generated-autoload-file have Unix EOLs, so
453 ;; that it is portable to all platforms.
454 (setq buffer-file-coding-system
'raw-text-unix
))
455 (or (> (buffer-size) 0)
456 (error "Autoloads file %s does not exist" buffer-file-name
))
457 (or (file-writable-p buffer-file-name
)
458 (error "Autoloads file %s is not writable"
461 ;;;_ . elinstall-update-deffile
463 ;;Adapted from autoload.el `update-directory-autoloads'.
465 (defun elinstall-update-deffile (target actions
&optional
468 Update file TARGET with current autoloads as specified by ACTIONS.
469 Also remove any old definitions pointing to libraries that can no
472 ACTIONS must be a list of actions (See the format doc). Each one's
473 filename must be relative to some element of load-path.
475 USE-LOAD-PATH is a list to use as load-path. It should include
476 any new load-path that we are arranging to create. If it's not given,
477 load-path itself is used.
479 If FORCE is `t', do it regardless of timestamps etc. (Not implemented)
480 Other non-nil cases of FORCE are reserved for future development.
482 This uses `update-file-autoloads' (which see) to do its work.
483 In an interactive call, you must give one argument, the name
484 of a single directory."
487 (use-load-path (or use-load-path load-path
))
488 (this-time (current-time))
489 ;;files with no autoload cookies.
492 (elinstall-prepare-deffile target
)
494 (find-file-noselect target
)
497 (elinstall-remove-autogen-action
498 (autoload-trim-file-name target
)
501 (goto-char (point-min))
502 (while (search-forward generate-autoload-section-header nil t
)
503 (let* ((form (autoload-read-section-header))
505 (cond ((and (consp file
) (stringp (car file
)))
506 ;; This is a list of files that have no
508 ;; There shouldn't be more than one such entry.
509 ;; Remove the obsolete section.
510 (autoload-remove-section (match-beginning 0))
511 (let ((last-time (nth 4 form
)))
513 (let ((file-time (nth 5 (file-attributes file
))))
515 (not (time-less-p last-time file-time
)))
517 (push file no-autoloads
)
519 (elinstall-remove-autogen-action
521 ((not (stringp file
)))
525 (locate-library file nil use-load-path
)))
527 ;;File doesn't exist, so remove its
530 (autoload-remove-section
531 (match-beginning 0)))
533 ;; File hasn't changed, so do nothing.
536 (nth 5 (file-attributes file-path
)))
539 (elinstall-deffile-insert
540 (elinstall-get-autogen-action
544 (elinstall-remove-autogen-action
547 ;; Remaining actions have no existing autoload sections yet.
550 (delq nil
(mapcar #'elinstall-deffile-insert actions
))))
552 ;; Sort them for better readability.
553 (setq no-autoloads
(sort no-autoloads
'string
<))
554 ;; Add the `no-autoloads' section.
555 (goto-char (point-max))
556 (search-backward "\f" nil t
)
558 (elinstall-insert-section-header
560 (list 'autoloads nil nil no-autoloads this-time
))
561 (insert generate-autoload-section-trailer
))
564 ;;;_ . elinstall-stage-update-deffiles
565 (defun elinstall-stage-update-deffiles (segment-list force use-load-path
)
566 "Update any deffiles mentioned in SEGMENT-LIST.
567 FORCE and USE-LOAD-PATH have the same meaning as in
568 `elinstall-update-deffile'.
573 ((deffile (car segment
)))
574 (if (stringp deffile
)
575 (elinstall-update-deffile deffile
(cdr segment
) force
579 ;;;_ , Doing actions to arrange preloads
580 ;;;_ . elinstall-symlink-on-emacs-start
581 (defun elinstall-symlink-on-emacs-start
582 (filename target-basename target-dir
&optional priority force
)
583 "Symlink to TARGET-BASENAME.el in TARGET-DIR
585 If PRIORITY is given, it will be used as the priority prefix,
586 otherwise elinstall-default-priority will be.
587 PRIORITY must be an integer or nil.
588 If FORCE is `t', do it regardless of timestamps etc.
589 Other non-nil cases of FORCE are reserved for future development."
592 (priority (or priority elinstall-default-priority
))
599 (expand-file-name target-name-nodir target-dir
)))
603 ;;Path should already exist.
605 (file-exists-p target-dir
))
606 (message "The target directory doesn't exist."))
607 ;;Target shouldn't already exist, but if force is given, let
609 ;;$$IMPROVE ME If it is a symlink pointing to the same place,
610 ;;do nothing even on force.
612 (file-exists-p target
)
617 (format "Really overwrite %s? " target
))))
618 (message "File %s already exists" target
)))
626 ;;;_ . elinstall-add-to-dot-emacs
627 (defun elinstall-add-to-dot-emacs (dot-emacs-name filename force
&rest r
)
628 "Add code to load FILENAME to .emacs.
629 FILENAME should not have an extension"
632 (with-current-buffer (find-file-noselect dot-emacs-name
)
635 (goto-char (point-max))
636 (insert "\n;;Added by elinstall")
637 (insert "\n;;Consider using my-site-start to manage .emacs\n")
638 (pp `(load ,filename
) (current-buffer))
642 ;;;_ . elinstall-arrange-preload
644 (defun elinstall-arrange-preload (force filename basename
&optional priority
)
645 "Arrange for FILENAME to be loaded on emacs start.
646 FORCE has its usual meaning.
647 BASENAME and PRIORITY are used as arguments to
648 `elinstall-symlink-on-emacs-start'.
652 ((preload-target elinstall-default-preload-target
))
654 ;;Dispatch the possibilities.
656 ((eq preload-target
'dot-emacs
)
657 (elinstall-add-to-dot-emacs "~/.emacs" filename force
))
658 ((stringp preload-target
)
659 (elinstall-symlink-on-emacs-start
660 filename basename preload-target priority force
))
661 ((null preload-target
)
662 (message "Not arranging for preloads"))
664 (message "I don't recognize that")))))
665 ;;;_ . elinstall-stage-arrange-preloads
666 (defun elinstall-stage-arrange-preloads (actions deffiles-used
)
667 "Arrange any preloads mentioned in ACTIONS."
681 (member filename deffiles-used
)))))
685 #'elinstall-arrange-preload
690 "elinstall-stage-arrange-preloads: Action not
696 ;;;_ . elinstall-stage-run-tests
697 (defun elinstall-stage-run-tests (actions)
698 "Run any tests mentioned in ACTIONS."
704 ;;$$WRITE ME - not a high priority right now.
708 "elinstall-stage-run-tests: Action not
714 ;;;_ . elinstall-stage-byte-compile
715 (defun elinstall-stage-byte-compile (actions)
716 "Do any byte-compilation mentioned in ACTIONS."
721 ;;$$IMPROVE ME Understand flags to control second
722 ;;argument (whether to load file after
725 (byte-compile-file (second act
)))
728 "elinstall-stage-byte-compile: Action not
731 ;;;_ . Segregating actions
732 ;;;_ , elinstall-remove-empty-segs
733 (defun elinstall-remove-empty-segs (segment-list)
734 "Return SEGMENT-LIST minus any segments that have no actions.
735 Intended only for the deffile stage data."
744 ;;;_ , elinstall-segregate-actions
745 (defun elinstall-segregate-actions (actions)
746 "Return actions segregated by deffile.
748 Returns a list whose elements are each a cons of:
749 * deffile filename or nil
750 * A list of actions to be done for that deffile."
757 (arrange-preloads '()))
759 (dolist (act actions
)
766 ((deffile-name (second act
))
768 (assoc deffile-name build-deffiles
)))
770 ;;There are already actions on this deffile.
771 ;;Splice this action in.
773 (cons act
(cdr cell-already
)))
774 ;;There are no actions on this deffile. Add a
775 ;;place for them and include this action.
776 (push (list deffile-name act
) build-deffiles
))))
778 (push act arrange-preloads
))
780 (push act run-tests
))
782 (push act byte-compile
)))))
784 (elinstall-make-stages
786 (elinstall-remove-empty-segs build-deffiles
)
793 ;;;_ . Finding actions
794 ;;;_ , Treating the parameter list
795 ;;;_ . elinstall-add-parameter
796 (defun elinstall-add-parameter (alist key new-value
)
797 "Add a new value for KEY to ALIST"
801 (assq-delete-all key
(copy-list alist
))))
803 ;;;_ . elinstall-get-parameter
804 (defun elinstall-get-parameter (alist key
)
805 "Get the value of KEY from ALIST"
807 (cdr (assq key alist
)))
808 ;;;_ . elinstall-expand-file-name
811 (defun elinstall-expand-file-name (filename alist
)
812 "Expand FILENAME by the value of `path' in ALIST"
815 (elinstall-get-parameter alist
'path
)))
816 ;;;_ , Finding deffiles
817 ;;;_ . elinstall-expand-deffile-name
818 (defun elinstall-expand-deffile-name (deffile)
819 "Expand DEFFILE autoload.el's way."
821 (expand-file-name (or deffile
"loaddefs.el")
822 (expand-file-name "lisp"
825 ;;;_ . elinstall-maybe-get-deffile
826 (defun elinstall-maybe-get-deffile (file)
827 "If FILE defined `generated-autoload-file', return it.
828 Otherwise return nil.
829 Return it as an absolute filename."
832 ;;$$FIXME load buffer if it's not already loaded
834 ((existing-buffer (get-file-buffer file
)))
836 ;; We want to get a value for generated-autoload-file from
837 ;; the local variables section if it's there.
838 ;;But if it's not loaded, we don't? Maybe should use
839 ;; `autoload-find-file' and load it.
841 (set-buffer existing-buffer
))
842 (if (local-variable-p 'generated-autoload-file
)
843 (elinstall-expand-deffile-name
844 generated-autoload-file
)
847 ;;;_ . elinstall-dir-has-info
849 ;;$$IMPROVE ME - Can this test be made more precise?
850 (defun elinstall-dir-has-info (dir)
851 "Return non-nil if DIR has info files in it.
852 DIR should be an absolute path."
854 (string-match "/info/" dir
)
855 (directory-files dir nil
"\\.info\\(-[0-9]+\\)?\\(\\.gz\\)?$")))
858 ;;;_ , List of special variables used here
859 ;;load-path-element - The relevant element of load-path
860 ;;def-file - The file the autoload definitions etc will go into.
861 ;;add-to-load-path-p - Controls whether to add to load-path.
863 ;;;_ , elinstall-actions-for-source-file
864 (defun elinstall-actions-for-source-file (filename dir
)
865 "Return a list of actions to do for FILENAME in DIR.
866 Special variables are as noted in \"List of special variables\"."
870 ;;$$IMPROVE ME take and treat a "force" argument.
873 (expand-file-name filename dir
))
874 ;;$$IMPROVE ME - take into account local no-byte-compile flag.
877 (featurep 'byte-compile
)
878 (string-match emacs-lisp-file-regexp filename
)
879 (file-readable-p full-path
)
880 (not (auto-save-file-name-p full-path
))
882 ((dest (byte-compile-dest-file full-path
))
883 ;;$$PUNT - currently, we wouldn't have gotten
884 ;;here if we weren't intending to do everything.
887 (if (file-exists-p dest
)
888 ;; File was already compiled.
889 (or recompile-p
(file-newer-than-file-p full-path dest
))
891 (y-or-n-p (concat "Compile " filename
"? "))))))))
896 `(byte-compile ,full-path
)
900 ;;load-name relative to a member of load-path
901 ,(file-name-sans-extension
907 ;;;_ , elinstall-find-actions-by-spec-x
909 (defun elinstall-find-actions-by-spec-x (spec path
)
910 "Return a list of actions to do, controlled by SPEC."
912 load-path-element def-file add-to-load-path-p
))
915 ;;$$IMPROVE ME by adding the other cases in the design.
924 (elinstall-find-actions-by-spec-x
932 (elinstall-find-actions-by-spec-x
938 (elinstall-actions-for-source-file
940 ;;$$ADD ME control, rather than trying to bind all control
941 ;;variables so we can safely bind one, will use set and
955 elinstall-elisp-regexp
))
958 elisp-source-files
;;List not empty.
966 ;;$$IMPROVE ME - remove the current deffile from
968 ;;Maybe arrange to add this directory to load-path.
975 ;;$$IMPROVE ME - be controlled by a control variable.
976 ;;If any info files are present, do add-to-info-path
979 (elinstall-dir-has-info dirname
)
987 ;; We want to get a value for generated-autoload-file
988 ;; from the local variables section if it's there.
989 ;;Use `elinstall-maybe-get-deffile'
992 ;;$$FIXME Don't do directories, but maybe recurse on
993 ;;them, if a flag is set.
994 ;;Maybe could follow/not symlinks similarly.
998 (elinstall-actions-for-source-file
1001 elisp-source-files
)))))
1005 `((add-to-load-path ,def-file
,path
))
1007 ((load-path-element path
))
1008 (elinstall-find-actions-by-spec-x path dir
))))
1017 (for-preload (third spec
)))
1018 (assert (listp for-preload
))
1022 (and for-preload
(car for-preload
))
1026 ,@(cdr for-preload
))
1029 (elinstall-find-actions-by-spec-x
1030 (fourth spec
) dir
)))))
1032 ;;$$IMPROVE ME by adding the other cases in the design.
1035 ;;;_ , elinstall-find-actions-by-spec
1036 (defun elinstall-find-actions-by-spec (spec load-path-element path def-file
)
1040 ((load-path-element load-path-element
)
1042 (add-to-load-path-p t
))
1044 load-path-element def-file add-to-load-path-p
))
1046 (elinstall-find-actions-by-spec-x
1049 ;;;_ . high-level work
1050 ;;;_ , elinstall-get-relevant-load-path
1051 (defun elinstall-get-relevant-load-path (actions)
1061 ;;;_ , elinstall-get-deffile-list
1062 (defun elinstall-get-deffile-list (stages)
1063 "Get a list of deffile names"
1067 (elinstall-stages->build-deffiles stages
)))
1070 (defun elinstall-x (dir spec
&optional force
)
1074 ;;This is just the default deffile, spec can override it.
1076 (elinstall-expand-deffile-name nil
))
1078 (elinstall-find-actions-by-spec
1083 (stages (elinstall-segregate-actions actions
))
1085 (elinstall-get-relevant-load-path
1088 (elinstall-stage-update-deffiles
1089 (elinstall-stages->build-deffiles stages
)
1092 (elinstall-stage-arrange-preloads
1093 (elinstall-stages->arrange-preloads stages
)
1094 (elinstall-get-deffile-list stages
))
1095 (elinstall-stage-byte-compile
1096 (elinstall-stages->byte-compile stages
))
1101 (defun elinstall (project-name path spec
&optional force
)
1102 "Install elisp files.
1103 They need not be a formal package.
1107 PROJECT-NAME - the name of the project
1109 PATH - Path to the project.
1110 Suggestion: (elinstall-directory-true-name)
1112 SPEC - a spec for the autoloads etc to make. It can be as simple as
1113 \(dir \"\.\") for installing one directory.
1115 If FORCE is t, install a package even if it has already been
1116 installed. Other non-nil cases of FORCE are reserved for future
1123 (not (elinstall-already-installed project-name
)))
1124 (yes-or-no-p (format "Re-install %s? " project-name
)))
1127 `(def-file "loaddefs.el" (if-used ,project-name
) ,spec
)
1129 (elinstall-record-installed project-name
)))
1133 ;;;_ . elinstall-update-directory-autoloads
1134 ;;$$SPLIT ME - one to just classically update autoloads, one to
1138 (defun elinstall-update-directory-autoloads (dir)
1141 (interactive "DInstall all elisp files from directory: ")
1146 (elinstall-expand-deffile-name
1147 generated-autoload-file
)))
1151 `(def-file ,def-file-name
(nil) (dir ".")))))
1155 ;;;_ . elinstall-update-file-autoloads
1156 ;;$$SPLIT ME - one to just classically update autoloads, one to
1160 (defun elinstall-update-file-autoloads (file)
1163 (interactive "fInstall elisp file: ")
1167 (elinstall-maybe-get-deffile file
)
1168 (elinstall-expand-deffile-name
1169 generated-autoload-file
))))
1172 `(def-file ,def-file-name
(nil) (file ,file
)))))
1176 (provide 'elinstall
)
1178 ;;;_ * Local emacs vars.
1179 ;;;_ + Local variables:
1184 ;;; elinstall.el ends here