diff options
| author | Glenn Morris | 2017-05-09 13:03:04 -0400 |
|---|---|---|
| committer | Glenn Morris | 2017-05-09 13:03:04 -0400 |
| commit | d6d5020c2593a1e8ac2fe7ef4f217cfbcacfd32d (patch) | |
| tree | b789728cd6a11281d5f5735c4490b28a94bbc3df | |
| parent | 4c08509b3a250781039b9f957a9615ea9afe6aa9 (diff) | |
| download | emacs-d6d5020c2593a1e8ac2fe7ef4f217cfbcacfd32d.tar.gz emacs-d6d5020c2593a1e8ac2fe7ef4f217cfbcacfd32d.zip | |
Don't duplicate autoload code in package.el
* lisp/emacs-lisp/autoload.el (autoload-rubric): Add a package option.
* lisp/emacs-lisp/package.el (autoload-rubric): Declare.
(package-autoload-ensure-default-file): Use autoload-rubric.
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 30 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 20 |
2 files changed, 23 insertions, 27 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 8ad5e6b823d..f6b09dcf31d 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el | |||
| @@ -355,24 +355,32 @@ put the output in." | |||
| 355 | (defun autoload-rubric (file &optional type feature) | 355 | (defun autoload-rubric (file &optional type feature) |
| 356 | "Return a string giving the appropriate autoload rubric for FILE. | 356 | "Return a string giving the appropriate autoload rubric for FILE. |
| 357 | TYPE (default \"autoloads\") is a string stating the type of | 357 | TYPE (default \"autoloads\") is a string stating the type of |
| 358 | information contained in FILE. If FEATURE is non-nil, FILE | 358 | information contained in FILE. TYPE \"package\" acts like the default, |
| 359 | will provide a feature. FEATURE may be a string naming the | 359 | but adds an extra line to the output to modify `load-path'. |
| 360 | feature, otherwise it will be based on FILE's name. | 360 | |
| 361 | If FEATURE is non-nil, FILE will provide a feature. FEATURE may | ||
| 362 | be a string naming the feature, otherwise it will be based on | ||
| 363 | FILE's name. | ||
| 361 | 364 | ||
| 362 | At present, a feature is in fact always provided, but this should | 365 | At present, a feature is in fact always provided, but this should |
| 363 | not be relied upon." | 366 | not be relied upon." |
| 364 | (let ((basename (file-name-nondirectory file))) | 367 | (let ((basename (file-name-nondirectory file)) |
| 368 | (lp (if (equal type "package") (setq type "autoloads")))) | ||
| 365 | (concat ";;; " basename | 369 | (concat ";;; " basename |
| 366 | " --- automatically extracted " (or type "autoloads") "\n" | 370 | " --- automatically extracted " (or type "autoloads") "\n" |
| 367 | ";;\n" | 371 | ";;\n" |
| 368 | ";;; Code:\n\n" | 372 | ";;; Code:\n\n" |
| 369 | "\n" | 373 | (if lp |
| 370 | ;; This is used outside of autoload.el, eg cus-dep, finder. | 374 | ;; `load-path' should contain only directory names. |
| 371 | "(provide '" | 375 | "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\n" |
| 372 | (if (stringp feature) | 376 | (concat |
| 373 | feature | 377 | ;; This is used outside of autoload.el, eg cus-dep, finder. |
| 374 | (file-name-sans-extension basename)) | 378 | "\n" |
| 375 | ")\n" | 379 | "(provide '" |
| 380 | (if (stringp feature) | ||
| 381 | feature | ||
| 382 | (file-name-sans-extension basename)) | ||
| 383 | ")\n")) | ||
| 376 | ";; Local Variables:\n" | 384 | ";; Local Variables:\n" |
| 377 | ";; version-control: never\n" | 385 | ";; version-control: never\n" |
| 378 | ";; no-byte-compile: t\n" | 386 | ";; no-byte-compile: t\n" |
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 7ae7ffff1a7..c0ecb0447f3 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -905,25 +905,13 @@ untar into a directory named DIR; otherwise, signal an error." | |||
| 905 | nil pkg-file nil 'silent)))) | 905 | nil pkg-file nil 'silent)))) |
| 906 | 906 | ||
| 907 | ;;;; Autoload | 907 | ;;;; Autoload |
| 908 | ;; From Emacs 22, but changed so it adds to load-path. | 908 | (declare-function autoload-rubric "autoload" (file &optional type feature)) |
| 909 | |||
| 909 | (defun package-autoload-ensure-default-file (file) | 910 | (defun package-autoload-ensure-default-file (file) |
| 910 | "Make sure that the autoload file FILE exists and if not create it." | 911 | "Make sure that the autoload file FILE exists and if not create it." |
| 911 | (unless (file-exists-p file) | 912 | (unless (file-exists-p file) |
| 912 | (write-region | 913 | (require 'autoload) |
| 913 | (concat ";;; " (file-name-nondirectory file) | 914 | (write-region (autoload-rubric file "package" nil) nil file nil 'silent)) |
| 914 | " --- automatically extracted autoloads\n" | ||
| 915 | ";;\n" | ||
| 916 | ";;; Code:\n" | ||
| 917 | ;; `load-path' should contain only directory names | ||
| 918 | "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n" | ||
| 919 | "\n;; Local Variables:\n" | ||
| 920 | ";; version-control: never\n" | ||
| 921 | ";; no-byte-compile: t\n" | ||
| 922 | ";; no-update-autoloads: t\n" | ||
| 923 | ";; End:\n" | ||
| 924 | ";;; " (file-name-nondirectory file) | ||
| 925 | " ends here\n") | ||
| 926 | nil file nil 'silent)) | ||
| 927 | file) | 915 | file) |
| 928 | 916 | ||
| 929 | (defvar generated-autoload-file) | 917 | (defvar generated-autoload-file) |