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.
This commit is contained in:
parent
4c08509b3a
commit
d6d5020c25
2 changed files with 23 additions and 27 deletions
|
@ -355,24 +355,32 @@ put the output in."
|
||||||
(defun autoload-rubric (file &optional type feature)
|
(defun autoload-rubric (file &optional type feature)
|
||||||
"Return a string giving the appropriate autoload rubric for FILE.
|
"Return a string giving the appropriate autoload rubric for FILE.
|
||||||
TYPE (default \"autoloads\") is a string stating the type of
|
TYPE (default \"autoloads\") is a string stating the type of
|
||||||
information contained in FILE. If FEATURE is non-nil, FILE
|
information contained in FILE. TYPE \"package\" acts like the default,
|
||||||
will provide a feature. FEATURE may be a string naming the
|
but adds an extra line to the output to modify `load-path'.
|
||||||
feature, otherwise it will be based on FILE's name.
|
|
||||||
|
If FEATURE is non-nil, FILE will provide a feature. FEATURE may
|
||||||
|
be a string naming the feature, otherwise it will be based on
|
||||||
|
FILE's name.
|
||||||
|
|
||||||
At present, a feature is in fact always provided, but this should
|
At present, a feature is in fact always provided, but this should
|
||||||
not be relied upon."
|
not be relied upon."
|
||||||
(let ((basename (file-name-nondirectory file)))
|
(let ((basename (file-name-nondirectory file))
|
||||||
|
(lp (if (equal type "package") (setq type "autoloads"))))
|
||||||
(concat ";;; " basename
|
(concat ";;; " basename
|
||||||
" --- automatically extracted " (or type "autoloads") "\n"
|
" --- automatically extracted " (or type "autoloads") "\n"
|
||||||
";;\n"
|
";;\n"
|
||||||
";;; Code:\n\n"
|
";;; Code:\n\n"
|
||||||
"\n"
|
(if lp
|
||||||
;; This is used outside of autoload.el, eg cus-dep, finder.
|
;; `load-path' should contain only directory names.
|
||||||
"(provide '"
|
"(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\n"
|
||||||
(if (stringp feature)
|
(concat
|
||||||
feature
|
;; This is used outside of autoload.el, eg cus-dep, finder.
|
||||||
(file-name-sans-extension basename))
|
"\n"
|
||||||
")\n"
|
"(provide '"
|
||||||
|
(if (stringp feature)
|
||||||
|
feature
|
||||||
|
(file-name-sans-extension basename))
|
||||||
|
")\n"))
|
||||||
";; Local Variables:\n"
|
";; Local Variables:\n"
|
||||||
";; version-control: never\n"
|
";; version-control: never\n"
|
||||||
";; no-byte-compile: t\n"
|
";; no-byte-compile: t\n"
|
||||||
|
|
|
@ -905,25 +905,13 @@ untar into a directory named DIR; otherwise, signal an error."
|
||||||
nil pkg-file nil 'silent))))
|
nil pkg-file nil 'silent))))
|
||||||
|
|
||||||
;;;; Autoload
|
;;;; Autoload
|
||||||
;; From Emacs 22, but changed so it adds to load-path.
|
(declare-function autoload-rubric "autoload" (file &optional type feature))
|
||||||
|
|
||||||
(defun package-autoload-ensure-default-file (file)
|
(defun package-autoload-ensure-default-file (file)
|
||||||
"Make sure that the autoload file FILE exists and if not create it."
|
"Make sure that the autoload file FILE exists and if not create it."
|
||||||
(unless (file-exists-p file)
|
(unless (file-exists-p file)
|
||||||
(write-region
|
(require 'autoload)
|
||||||
(concat ";;; " (file-name-nondirectory file)
|
(write-region (autoload-rubric file "package" nil) nil file nil 'silent))
|
||||||
" --- automatically extracted autoloads\n"
|
|
||||||
";;\n"
|
|
||||||
";;; Code:\n"
|
|
||||||
;; `load-path' should contain only directory names
|
|
||||||
"(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n"
|
|
||||||
"\n;; Local Variables:\n"
|
|
||||||
";; version-control: never\n"
|
|
||||||
";; no-byte-compile: t\n"
|
|
||||||
";; no-update-autoloads: t\n"
|
|
||||||
";; End:\n"
|
|
||||||
";;; " (file-name-nondirectory file)
|
|
||||||
" ends here\n")
|
|
||||||
nil file nil 'silent))
|
|
||||||
file)
|
file)
|
||||||
|
|
||||||
(defvar generated-autoload-file)
|
(defvar generated-autoload-file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue