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 ;;;_ . elinstall-insert-section-header
162 (defun elinstall-insert-section-header (outbuf form
)
163 "Insert the section-header line,
164 which lists the file name and which functions are in it, etc."
165 (insert generate-autoload-section-header
)
168 ;; Break that line at spaces, to avoid very long lines.
169 ;; Make each sub-line into a comment.
170 (with-current-buffer outbuf
175 (skip-chars-forward "^ \n")
177 (insert "\n" generate-autoload-section-continuation
))))))
179 ;;;_ . Making autoloads
180 ;;;_ , elinstall-insert-autoload-section
181 '(elinstall-insert-autoload-section
186 (autoload-trim-file-name full-name
)
187 (nth 5 (file-attributes full-name
)))
189 "Generated autoloads from "
190 (autoload-trim-file-name full-name
)))
192 (defun elinstall-insert-autoload-section (text form
&optional comment-string
)
193 "Insert TEXT into current buffer as an autoload section"
195 ;; Insert the section-header line which lists the file name
196 ;; and which functions are in it, etc.
198 (elinstall-insert-section-header (current-buffer) form
)
201 (insert ";;; " comment-string
"\n"))
203 (insert generate-autoload-section-trailer
))
205 ;;;_ , elinstall-make-autoload-action
206 (defun elinstall-make-autoload-action (buf def-file load-path-element full-path
)
207 "Return the autoloads for current buffer as a string"
209 ;;We put all the text into a temp buffer, then get that buffer's
213 (generate-new-buffer " *temp*"))
218 (file-name-sans-extension
221 load-path-element
))))
223 (message "Finding autoloads for %s..." short-name
)
224 (with-current-buffer buf
229 (goto-char (point-min))
231 (skip-chars-forward " \t\n\f")
233 ((looking-at (regexp-quote generate-autoload-cookie
))
234 (search-forward generate-autoload-cookie
)
235 (skip-chars-forward " \t")
238 ;; Read the next form and make an autoload.
239 (let* ((form (prog1 (read (current-buffer))
240 (or (bolp) (forward-line 1))))
242 (make-autoload form relative-name
)))
244 (push (nth 1 form
) autoloads-done
)
245 (setq autoload form
))
246 (let ((autoload-print-form-outbuf outbuf
))
247 (autoload-print-form autoload
)))
249 ;; Copy the rest of the line to the output.
250 (princ (buffer-substring
252 ;; Back up over whitespace,
254 (skip-chars-backward " \f\t")
255 (if (= (char-after (1+ (point))) ?
)
259 (progn (forward-line 1) (point)))
262 ;; Don't read the comment.
269 (message "Finding autoloads for %s...done" short-name
)
271 ;;Return this action. The temp buffer's contents is
275 ;;load-name relative to a member of load-path.
279 ,(with-current-buffer outbuf
(buffer-string))))
281 ;;The unwind-protected part
282 (when (buffer-live-p outbuf
) (kill-buffer outbuf
))))))
285 ;;;_ , elinstall-generate-file-autoloads
286 ;;override to allow slashed load-paths
287 ;;Quick and dirty: We just adapt `generate-file-autoloads' and add
289 ;;`relative-to' can be:
290 ;; * nil: act as at present. Assume that FILE's immediate directory
292 ;; * t :: use default-directory
293 ;; * a string :: relative to it, as a filename
295 (defun elinstall-generate-file-autoloads (relative-name full-name text
)
296 "Insert at point a loaddefs autoload section for FILE.
297 Autoloads are generated for defuns and defmacros in FILE
298 marked by `generate-autoload-cookie' (which see).
299 If FILE is being visited in a buffer, the contents of the buffer
301 Return non-nil in the case where no autoloads were added at point.
303 FULL-NAME is the absolute name of the file.
304 RELATIVE-NAME is its name respective to some component of load-path."
305 (let* ((outbuf (current-buffer))
308 (print-readably t
) ; This does something in Lucid Emacs.
309 (float-output-format nil
)
311 (visited (get-file-buffer full-name
))
314 ;; It is faster to avoid visiting the file.
315 (ignore-errors (autoload-find-file full-name
))))
318 (with-current-buffer source-buf
319 (message "Generating autoloads for %s..." relative-name
)
320 (setq output-start
(with-current-buffer outbuf
(point)))
324 (goto-char (point-min))
326 (skip-chars-forward " \t\n\f")
328 ((looking-at (regexp-quote generate-autoload-cookie
))
329 (search-forward generate-autoload-cookie
)
330 (skip-chars-forward " \t")
333 ;; Read the next form and make an autoload.
334 (let* ((form (prog1 (read (current-buffer))
335 (or (bolp) (forward-line 1))))
337 (make-autoload form relative-name
)))
339 (push (nth 1 form
) autoloads-done
)
340 (setq autoload form
))
341 (let ((autoload-print-form-outbuf outbuf
))
342 (autoload-print-form autoload
)))
344 ;; Copy the rest of the line to the output.
345 (princ (buffer-substring
347 ;; Back up over whitespace, to preserve it.
348 (skip-chars-backward " \f\t")
349 (if (= (char-after (1+ (point))) ?
)
353 (progn (forward-line 1) (point)))
356 ;; Don't read the comment.
360 (forward-line 1))))))
363 (with-current-buffer outbuf
365 ;; Insert the section-header line which lists the file name
366 ;; and which functions are in it, etc.
367 (goto-char output-start
)
368 (elinstall-insert-section-header
373 (autoload-trim-file-name full-name
)
374 (nth 5 (file-attributes full-name
))))
376 (insert ";;; Generated autoloads from "
377 (autoload-trim-file-name full-name
) "\n"))
378 (insert generate-autoload-section-trailer
)))
379 (message "Generating autoloads for %s...done" relative-name
))
382 ;; We created this buffer, so we should kill it.
383 (kill-buffer (current-buffer)))
384 (message "Could not load %s" relative-name
))
389 ;;;_ , elinstall-deffile-insert-autoloads
390 (defun elinstall-deffile-insert-autoloads (file load-name text
)
391 "Update the autoloads for FILE in current buffer.
392 Return FILE if there was no autoload cookie in it, else nil.
394 Current buffer must be a loaddef-style file.
396 LOAD-NAME is the absolute name of the file.
397 RELATIVE-NAME is its name respective to some component of load-path."
405 (goto-char (point-min))
406 ;; Look for the section for FILE
407 (while (and (not found
)
408 (search-forward generate-autoload-section-header nil t
))
409 (let ((form (autoload-read-section-header)))
411 ((equal (nth 2 form
) file
)
412 ;; We found the section for this file.
413 (let ((begin (match-beginning 0)))
415 (search-forward generate-autoload-section-trailer
)
416 (delete-region begin
(point))
418 ((string< file
(nth 2 form
))
419 ;; We've come to a section alphabetically later than
420 ;; FILE. We assume the file is in order and so
421 ;; there must be no section for FILE. We will
422 ;; insert one before the section here.
423 (goto-char (match-beginning 0))
424 (setq found
'new
)))))
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-file-autoloads file load-name text
))))
434 (if no-autoloads file nil
)))
435 ;;;_ . Arranging to add to info-path and load-path
436 ;;;_ , elinstall-generate-add-to-path
437 (defun elinstall-generate-add-to-path (path-element type
)
438 "Insert code at point to add PATH-ELEMENT to a path.
440 * `add-to-load-path', add to load-path
441 * `add-to-info-path', add to Info-default-directory-list
443 Current buffer must be a loaddef-style file."
446 (add-to-load-path 'load-path
)
447 (add-to-info-path 'Info-default-directory-list
)
448 (t (error "Type not recognized"))))
451 (add-to-load-path "load-path")
452 (add-to-info-path "info-path")))
455 (print-readably t
) ; This does something in Lucid Emacs.
456 (float-output-format nil
))
458 (message "Generating %s additions..." description
)
461 (elinstall-insert-section-header
463 (list type
(list path-element
) nil nil nil
))
465 (insert ";;; Generated path addition\n")
467 `(add-to-list ',path-symbol
469 ,(file-relative-name path-element
)
472 (file-truename load-file-name
)))))
475 (insert generate-autoload-section-trailer
)
476 (message "Generating %s additions...done" description
)))
479 ;;;_ , elinstall-deffile-insert-add-to-path
480 (defun elinstall-deffile-insert-add-to-path (path-element type
)
481 "Insert code in current buffer to add PATH-ELEMENT to a path.
483 * `add-to-load-path', add to load-path
484 * `add-to-info-path', add to Info-default-directory-list
486 Current buffer must be a loaddef-style file."
494 (goto-char (point-min))
495 ;; Look for the section for PATH-ELEMENT
496 (while (and (not found
)
497 (search-forward generate-autoload-section-header nil t
))
498 (let ((form (autoload-read-section-header)))
501 (equal (nth 0 form
) type
)
502 (member path-element
(nth 1 form
)))
504 ;; We found the section for this add.
505 (let ((begin (match-beginning 0)))
507 (search-forward generate-autoload-section-trailer
)
508 (delete-region begin
(point))
514 ;; No later sections in the file. Put before the last page.
515 (goto-char (point-max))
516 (search-backward "\f" nil t
)))
518 (elinstall-generate-add-to-path path-element type
)))
520 ;;This never belongs in the no-autoloads section.
522 ;;;_ . elinstall-deffile-insert
524 (defun elinstall-deffile-insert (action)
525 "Insert autoloads etc into current file according to ACTION.
526 The format of ACTION is described in the design docs.
528 Return filename if this action belongs in the no-autoload section."
533 (elinstall-deffile-insert-autoloads
539 (elinstall-deffile-insert-add-to-path
545 (elinstall-deffile-insert-add-to-path
550 ((preload-file run-tests byte-compile
)
551 (error "This case should not come here.")))))
553 ;;;_ . elinstall-prepare-deffile
554 (defun elinstall-prepare-deffile (deffile)
555 "Try to ensure that DEFFILE is available for receiving autoloads"
557 (autoload-ensure-default-file deffile
)
558 (with-current-buffer (find-file-noselect deffile
)
561 ;; We must read/write the file without any code conversion,
562 ;; but still decode EOLs.
563 (let ((coding-system-for-read 'raw-text
))
565 ;; This is to make generated-autoload-file have Unix EOLs, so
566 ;; that it is portable to all platforms.
567 (setq buffer-file-coding-system
'raw-text-unix
))
568 (or (> (buffer-size) 0)
569 (error "Autoloads file %s does not exist" buffer-file-name
))
570 (or (file-writable-p buffer-file-name
)
571 (error "Autoloads file %s is not writable"
574 ;;;_ . elinstall-update-deffile
576 ;;Adapted from autoload.el `update-directory-autoloads'.
578 (defun elinstall-update-deffile (target actions
&optional
581 Update file TARGET with current autoloads as specified by ACTIONS.
582 Also remove any old definitions pointing to libraries that can no
585 ACTIONS must be a list of actions (See the format doc). Each one's
586 filename must be relative to some element of load-path.
588 USE-LOAD-PATH is a list to use as load-path. It should include
589 any new load-path that we are arranging to create. If it's not given,
590 load-path itself is used.
592 If FORCE is `t', do it regardless of timestamps etc. (Not implemented)
593 Other non-nil cases of FORCE are reserved for future development.
595 This uses `update-file-autoloads' (which see) to do its work.
596 In an interactive call, you must give one argument, the name
597 of a single directory."
600 (use-load-path (or use-load-path load-path
))
601 (this-time (current-time))
602 ;;files with no autoload cookies.
605 (elinstall-prepare-deffile target
)
607 (find-file-noselect target
)
610 (elinstall-remove-autogen-action
611 (autoload-trim-file-name target
)
614 (goto-char (point-min))
615 (while (search-forward generate-autoload-section-header nil t
)
616 (let* ((form (autoload-read-section-header))
618 (cond ((and (consp file
) (stringp (car file
)))
619 ;; This is a list of files that have no
621 ;; There shouldn't be more than one such entry.
622 ;; Remove the obsolete section.
623 (autoload-remove-section (match-beginning 0))
624 (let ((last-time (nth 4 form
)))
626 (let ((file-time (nth 5 (file-attributes file
))))
628 (not (time-less-p last-time file-time
)))
630 (push file no-autoloads
)
632 (elinstall-remove-autogen-action
634 ((not (stringp file
)))
638 (locate-library file nil use-load-path
)))
640 ;;File doesn't exist, so remove its
643 (autoload-remove-section
644 (match-beginning 0)))
646 ;; File hasn't changed, so do nothing.
649 (nth 5 (file-attributes file-path
)))
652 (elinstall-deffile-insert
653 (elinstall-get-autogen-action
657 (elinstall-remove-autogen-action
660 ;; Remaining actions have no existing autoload sections yet.
663 (delq nil
(mapcar #'elinstall-deffile-insert actions
))))
665 ;; Sort them for better readability.
666 (setq no-autoloads
(sort no-autoloads
'string
<))
667 ;; Add the `no-autoloads' section.
668 (goto-char (point-max))
669 (search-backward "\f" nil t
)
671 (elinstall-insert-section-header
673 (list 'autoloads nil nil no-autoloads this-time
))
674 (insert generate-autoload-section-trailer
))
677 ;;;_ . elinstall-stage-update-deffiles
678 (defun elinstall-stage-update-deffiles (segment-list force use-load-path
)
679 "Update any deffiles mentioned in SEGMENT-LIST.
680 FORCE and USE-LOAD-PATH have the same meaning as in
681 `elinstall-update-deffile'.
686 ((deffile (car segment
)))
687 (if (stringp deffile
)
688 (elinstall-update-deffile deffile
(cdr segment
) force
692 ;;;_ , Doing actions to arrange preloads
693 ;;;_ . elinstall-symlink-on-emacs-start
694 (defun elinstall-symlink-on-emacs-start
695 (filename target-basename target-dir
&optional priority force
)
696 "Symlink to TARGET-BASENAME.el in TARGET-DIR
698 If PRIORITY is given, it will be used as the priority prefix,
699 otherwise elinstall-default-priority will be.
700 PRIORITY must be an integer or nil.
701 If FORCE is `t', do it regardless of timestamps etc.
702 Other non-nil cases of FORCE are reserved for future development."
705 (priority (or priority elinstall-default-priority
))
712 (expand-file-name target-name-nodir target-dir
)))
716 ;;Path should already exist.
718 (file-exists-p target-dir
))
719 (message "The target directory doesn't exist."))
720 ;;Target shouldn't already exist, but if force is given, let
722 ;;$$IMPROVE ME If it is a symlink pointing to the same place,
723 ;;do nothing even on force.
725 (file-exists-p target
)
730 (format "Really overwrite %s? " target
))))
731 (message "File %s already exists" target
)))
739 ;;;_ . elinstall-add-to-dot-emacs
740 (defun elinstall-add-to-dot-emacs (dot-emacs-name filename force
&rest r
)
741 "Add code to load FILENAME to .emacs.
742 FILENAME should not have an extension"
745 (with-current-buffer (find-file-noselect dot-emacs-name
)
748 (goto-char (point-max))
749 (insert "\n;;Added by elinstall")
750 (insert "\n;;Consider using my-site-start to manage .emacs\n")
751 (pp `(load ,filename
) (current-buffer))
755 ;;;_ . elinstall-arrange-preload
757 (defun elinstall-arrange-preload (force filename basename
&optional priority
)
758 "Arrange for FILENAME to be loaded on emacs start.
759 FORCE has its usual meaning.
760 BASENAME and PRIORITY are used as arguments to
761 `elinstall-symlink-on-emacs-start'.
765 ((preload-target elinstall-default-preload-target
))
767 ;;Dispatch the possibilities.
769 ((eq preload-target
'dot-emacs
)
770 (elinstall-add-to-dot-emacs "~/.emacs" filename force
))
771 ((stringp preload-target
)
772 (elinstall-symlink-on-emacs-start
773 filename basename preload-target priority force
))
774 ((null preload-target
)
775 (message "Not arranging for preloads"))
777 (message "I don't recognize that")))))
778 ;;;_ . elinstall-stage-arrange-preloads
779 (defun elinstall-stage-arrange-preloads (actions deffiles-used force
)
780 "Arrange any preloads mentioned in ACTIONS."
794 (member filename deffiles-used
)))))
798 #'elinstall-arrange-preload
803 "elinstall-stage-arrange-preloads: Action not
809 ;;;_ . elinstall-stage-run-tests
810 (defun elinstall-stage-run-tests (actions)
811 "Run any tests mentioned in ACTIONS."
817 ;;$$WRITE ME - not a high priority right now.
821 "elinstall-stage-run-tests: Action not
827 ;;;_ . elinstall-stage-byte-compile
828 (defun elinstall-stage-byte-compile (actions)
829 "Do any byte-compilation mentioned in ACTIONS."
834 ;;$$IMPROVE ME Understand flags to control second
835 ;;argument (whether to load file after
838 (byte-compile-file (second act
)))
841 "elinstall-stage-byte-compile: Action not
844 ;;;_ . Segregating actions
845 ;;;_ , elinstall-remove-empty-segs
846 (defun elinstall-remove-empty-segs (segment-list)
847 "Return SEGMENT-LIST minus any segments that have no actions.
848 Intended only for the deffile stage data."
857 ;;;_ , elinstall-segregate-actions
858 (defun elinstall-segregate-actions (actions)
859 "Return actions segregated by deffile.
861 Returns a list whose elements are each a cons of:
862 * deffile filename or nil
863 * A list of actions to be done for that deffile."
870 (arrange-preloads '()))
872 (dolist (act actions
)
879 ((deffile-name (second act
))
881 (assoc deffile-name build-deffiles
)))
883 ;;There are already actions on this deffile.
884 ;;Splice this action in.
886 (cons act
(cdr cell-already
)))
887 ;;There are no actions on this deffile. Add a
888 ;;place for them and include this action.
889 (push (list deffile-name act
) build-deffiles
))))
891 (push act arrange-preloads
))
893 (push act run-tests
))
895 (push act byte-compile
)))))
897 (elinstall-make-stages
899 (elinstall-remove-empty-segs build-deffiles
)
906 ;;;_ . Finding actions
908 ;;;_ . elinstall-dir-has-info
910 ;;$$IMPROVE ME - Can this test be made more precise?
911 (defun elinstall-dir-has-info (dir)
912 "Return non-nil if DIR has info files in it.
913 DIR should be an absolute path."
915 (string-match "/info/" dir
)
916 (directory-files dir nil
"\\.info\\(-[0-9]+\\)?\\(\\.gz\\)?$")))
919 ;;;_ . List of special variables used in this section
920 ;;load-path-element - The relevant element of load-path
921 ;;def-file - The file the autoload definitions etc will go into.
922 ;;add-to-load-path-p - Controls whether to add to load-path.
924 ;;;_ . elinstall-actions-for-source-file
925 (defun elinstall-actions-for-source-file (filename dir
)
926 "Return a list of actions to do for FILENAME in DIR.
927 Special variables are as noted in \"List of special variables\"."
929 load-path-element def-file
))
932 (expand-file-name filename dir
)))
935 (file-readable-p full-path
)
936 (not (auto-save-file-name-p full-path
)))
937 ;;$$IMPROVE ME create and use relevant control variables.
940 (visited (get-file-buffer full-path
))
944 ;;Visit the file cheaply.
945 ;;hack-local-variables can give errors.
946 (ignore-errors (autoload-find-file full-path
))))
950 (with-current-buffer buf
951 (if (local-variable-p 'generated-autoload-file
)
952 (elinstall-expand-deffile-name
953 generated-autoload-file
)
956 ;;Figure out whether to run some actions, by file local vars.
959 (with-current-buffer buf
960 (not no-update-autoloads
))))
963 (featurep 'byte-compile
)
964 (string-match emacs-lisp-file-regexp filename
)
966 (with-current-buffer buf
967 (not no-byte-compile
)))
969 ((dest (byte-compile-dest-file full-path
))
970 ;;$$PUNT - currently, we wouldn't have
971 ;;gotten here if we weren't intending to do
972 ;;everything so set force variables accordingly.
975 (if (file-exists-p dest
)
976 ;; File was already compiled.
977 (or recompile-p
(file-newer-than-file-p full-path dest
))
979 (y-or-n-p (concat "Compile " filename
"? "))))))))
984 `(byte-compile ,full-path
)
987 (elinstall-make-autoload-action
988 buf def-file load-path-element full-path
)
990 (unless visited
(kill-buffer-if-not-modified buf
)))))))
992 ;;;_ . elinstall-find-actions-by-spec-x
994 (defun elinstall-find-actions-by-spec-x (spec dir
)
995 "Return a list of actions to do, controlled by SPEC."
997 load-path-element def-file add-to-load-path-p
))
1000 ;;$$IMPROVE ME by adding the other cases in the design.
1009 (elinstall-find-actions-by-spec-x
1016 #'(lambda (sub-spec)
1017 (elinstall-find-actions-by-spec-x
1023 (elinstall-actions-for-source-file
1025 ;;$$ADD ME control, rather than trying to bind all control
1026 ;;variables so we can safely bind one, will use set and
1035 ;;Relative filenames
1040 elinstall-elisp-regexp
))
1043 elisp-source-files
;;List not empty.
1044 add-to-load-path-p
))
1048 load-path-element
)))
1051 ;;$$IMPROVE ME - remove the current deffile from
1053 ;;Maybe arrange to add this directory to load-path.
1057 ,load-path-element
))
1060 ;;$$IMPROVE ME - be controlled by a control variable.
1061 ;;If any info files are present, do add-to-info-path
1064 (elinstall-dir-has-info dirname
)
1072 ;;$$FIXME Don't do directories, but maybe recurse on
1073 ;;them, if a flag is set.
1074 ;;Maybe could follow/not symlinks similarly.
1077 #'(lambda (filename)
1078 (elinstall-actions-for-source-file
1081 elisp-source-files
)))))
1085 `((add-to-load-path ,def-file
,dir
))
1087 ((load-path-element dir
))
1088 (elinstall-find-actions-by-spec-x spec dir
))))
1097 (for-preload (third spec
)))
1098 (assert (listp for-preload
))
1102 (and for-preload
(car for-preload
))
1106 ,@(cdr for-preload
))
1109 (elinstall-find-actions-by-spec-x
1110 (fourth spec
) dir
)))))
1112 ;;$$IMPROVE ME by adding the other cases in the design.
1115 ;;;_ . elinstall-find-actions-by-spec
1116 (defun elinstall-find-actions-by-spec (spec load-path-element dir def-file
)
1120 ((load-path-element load-path-element
)
1122 (add-to-load-path-p t
))
1124 load-path-element def-file add-to-load-path-p
))
1126 (elinstall-find-actions-by-spec-x
1129 ;;;_ . high-level work
1130 ;;;_ , elinstall-get-relevant-load-path
1131 (defun elinstall-get-relevant-load-path (actions)
1141 ;;;_ , elinstall-get-deffile-list
1142 (defun elinstall-get-deffile-list (stages)
1143 "Get a list of deffile names"
1147 (elinstall-stages->build-deffiles stages
)))
1150 (defun elinstall-x (dir spec
&optional force
)
1154 ;;This is just the default deffile, spec can override it.
1156 (elinstall-expand-deffile-name nil
))
1158 (elinstall-find-actions-by-spec
1163 (stages (elinstall-segregate-actions actions
))
1165 (elinstall-get-relevant-load-path
1168 (elinstall-stage-update-deffiles
1169 (elinstall-stages->build-deffiles stages
)
1172 (elinstall-stage-arrange-preloads
1173 (elinstall-stages->arrange-preloads stages
)
1174 (elinstall-get-deffile-list stages
)
1176 (elinstall-stage-byte-compile
1177 (elinstall-stages->byte-compile stages
))
1182 (defun elinstall (project-name path spec
&optional force
)
1183 "Install elisp files.
1184 They need not be a formal package.
1188 PROJECT-NAME - the name of the project
1190 PATH - Path to the project.
1191 Suggestion: (elinstall-directory-true-name)
1193 SPEC - a spec for the autoloads etc to make. It can be as simple as
1194 \(dir \"\.\") for installing one directory.
1196 If FORCE is t, install a package even if it has already been
1197 installed. Other non-nil cases of FORCE are reserved for future
1204 (not (elinstall-already-installed project-name
)))
1205 (yes-or-no-p (format "Re-install %s? " project-name
)))
1208 `(def-file "loaddefs.el" (if-used ,project-name
) ,spec
)
1210 (elinstall-record-installed project-name
)))
1214 ;;;_ . elinstall-update-directory-autoloads
1215 ;;$$SPLIT ME - one to just classically update autoloads, one to
1219 (defun elinstall-update-directory-autoloads (dir)
1222 (interactive "DInstall all elisp files from directory: ")
1227 (elinstall-expand-deffile-name
1228 generated-autoload-file
)))
1232 `(def-file ,def-file-name
(nil) (dir ".")))))
1236 ;;;_ . elinstall-update-file-autoloads
1237 ;;$$SPLIT ME - one to just classically update autoloads, one to
1241 (defun elinstall-update-file-autoloads (file)
1244 (interactive "fInstall elisp file: ")
1247 ;;This is the default. File local vars can override it.
1248 (elinstall-expand-deffile-name
1249 generated-autoload-file
)))
1252 `(def-file ,def-file-name
(nil) (file ,file
)))))
1256 (provide 'elinstall
)
1258 ;;;_ * Local emacs vars.
1259 ;;;_ + Local variables:
1264 ;;; elinstall.el ends here