mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-12 09:00:40 -08:00
Refactor for upcoming changes.
(autoload-generate-file-autoloads): New function extracted from generate-file-autoloads. Use file-relative-name. Delay computation of output-start to the first cookie. Remove done-any, replaced by output-start. (generate-file-autoloads): Use it. (autoload-find-destination): Make use of `begin' var.
This commit is contained in:
parent
57536a8371
commit
ceea9b1803
2 changed files with 34 additions and 30 deletions
|
|
@ -4,6 +4,11 @@
|
||||||
(autoload-find-destination): New function extracted from
|
(autoload-find-destination): New function extracted from
|
||||||
update-file-autoloads.
|
update-file-autoloads.
|
||||||
(update-file-autoloads): Use it.
|
(update-file-autoloads): Use it.
|
||||||
|
(autoload-generate-file-autoloads): New function extracted from
|
||||||
|
generate-file-autoloads. Use file-relative-name. Delay computation of
|
||||||
|
output-start to the first cookie. Remove done-any, replaced by
|
||||||
|
output-start.
|
||||||
|
(generate-file-autoloads): Use it.
|
||||||
|
|
||||||
2007-06-24 Jay Belanger <jay.p.belanger@gmail.com>
|
2007-06-24 Jay Belanger <jay.p.belanger@gmail.com>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -309,39 +309,32 @@ If FILE is being visited in a buffer, the contents of the buffer
|
||||||
are used.
|
are used.
|
||||||
Return non-nil in the case where no autoloads were added at point."
|
Return non-nil in the case where no autoloads were added at point."
|
||||||
(interactive "fGenerate autoloads for file: ")
|
(interactive "fGenerate autoloads for file: ")
|
||||||
(let ((outbuf (current-buffer))
|
(autoload-generate-file-autoloads file (current-buffer)))
|
||||||
(autoloads-done '())
|
|
||||||
|
(defun autoload-generate-file-autoloads (file outbuf)
|
||||||
|
"Insert an autoload section for FILE in the appropriate buffer.
|
||||||
|
Autoloads are generated for defuns and defmacros in FILE
|
||||||
|
marked by `generate-autoload-cookie' (which see).
|
||||||
|
If FILE is being visited in a buffer, the contents of the buffer are used.
|
||||||
|
OUTBUF is the buffer in which the autoload statements will be inserted.
|
||||||
|
Return non-nil in the case where no autoloads were added in the buffer."
|
||||||
|
(let ((autoloads-done '())
|
||||||
(load-name (autoload-file-load-name file))
|
(load-name (autoload-file-load-name file))
|
||||||
(print-length nil)
|
(print-length nil)
|
||||||
(print-readably t) ; This does something in Lucid Emacs.
|
(print-readably t) ; This does something in Lucid Emacs.
|
||||||
(float-output-format nil)
|
(float-output-format nil)
|
||||||
(done-any nil)
|
|
||||||
(visited (get-file-buffer file))
|
(visited (get-file-buffer file))
|
||||||
|
(absfile (expand-file-name file))
|
||||||
|
relfile
|
||||||
|
;; nil until we found a cookie.
|
||||||
output-start)
|
output-start)
|
||||||
|
|
||||||
;; If the autoload section we create here uses an absolute
|
|
||||||
;; file name for FILE in its header, and then Emacs is installed
|
|
||||||
;; under a different path on another system,
|
|
||||||
;; `update-autoloads-here' won't be able to find the files to be
|
|
||||||
;; autoloaded. So, if FILE is in the same directory or a
|
|
||||||
;; subdirectory of the current buffer's directory, we'll make it
|
|
||||||
;; relative to the current buffer's directory.
|
|
||||||
(setq file (expand-file-name file))
|
|
||||||
(let* ((source-truename (file-truename file))
|
|
||||||
(dir-truename (file-name-as-directory
|
|
||||||
(file-truename default-directory)))
|
|
||||||
(len (length dir-truename)))
|
|
||||||
(if (and (< len (length source-truename))
|
|
||||||
(string= dir-truename (substring source-truename 0 len)))
|
|
||||||
(setq file (substring source-truename len))))
|
|
||||||
|
|
||||||
(with-current-buffer (or visited
|
(with-current-buffer (or visited
|
||||||
;; It is faster to avoid visiting the file.
|
;; It is faster to avoid visiting the file.
|
||||||
(autoload-find-file file))
|
(autoload-find-file file))
|
||||||
;; Obey the no-update-autoloads file local variable.
|
;; Obey the no-update-autoloads file local variable.
|
||||||
(unless no-update-autoloads
|
(unless no-update-autoloads
|
||||||
(message "Generating autoloads for %s..." file)
|
(message "Generating autoloads for %s..." file)
|
||||||
(setq output-start (with-current-buffer outbuf (point)))
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
|
|
@ -350,9 +343,16 @@ Return non-nil in the case where no autoloads were added at point."
|
||||||
(skip-chars-forward " \t\n\f")
|
(skip-chars-forward " \t\n\f")
|
||||||
(cond
|
(cond
|
||||||
((looking-at (regexp-quote generate-autoload-cookie))
|
((looking-at (regexp-quote generate-autoload-cookie))
|
||||||
|
;; If not done yet, figure out where to insert this text.
|
||||||
|
(unless output-start
|
||||||
|
(with-current-buffer outbuf
|
||||||
|
(setq relfile (file-relative-name absfile))
|
||||||
|
(setq output-start (point)))
|
||||||
|
;; (message "file=%S, relfile=%S, dest=%S"
|
||||||
|
;; file relfile (autoload-generated-file))
|
||||||
|
)
|
||||||
(search-forward generate-autoload-cookie)
|
(search-forward generate-autoload-cookie)
|
||||||
(skip-chars-forward " \t")
|
(skip-chars-forward " \t")
|
||||||
(setq done-any t)
|
|
||||||
(if (eolp)
|
(if (eolp)
|
||||||
(condition-case err
|
(condition-case err
|
||||||
;; Read the next form and make an autoload.
|
;; Read the next form and make an autoload.
|
||||||
|
|
@ -385,23 +385,22 @@ Return non-nil in the case where no autoloads were added at point."
|
||||||
(forward-sexp 1)
|
(forward-sexp 1)
|
||||||
(forward-line 1))))))
|
(forward-line 1))))))
|
||||||
|
|
||||||
(when done-any
|
(when output-start
|
||||||
(with-current-buffer outbuf
|
(with-current-buffer outbuf
|
||||||
(save-excursion
|
(save-excursion
|
||||||
;; Insert the section-header line which lists the file name
|
;; Insert the section-header line which lists the file name
|
||||||
;; and which functions are in it, etc.
|
;; and which functions are in it, etc.
|
||||||
(goto-char output-start)
|
(goto-char output-start)
|
||||||
(autoload-insert-section-header
|
(autoload-insert-section-header
|
||||||
outbuf autoloads-done load-name file
|
outbuf autoloads-done load-name relfile
|
||||||
(nth 5 (file-attributes file)))
|
(nth 5 (file-attributes relfile)))
|
||||||
(insert ";;; Generated autoloads from "
|
(insert ";;; Generated autoloads from " relfile "\n"))
|
||||||
(autoload-trim-file-name file) "\n"))
|
|
||||||
(insert generate-autoload-section-trailer)))
|
(insert generate-autoload-section-trailer)))
|
||||||
(message "Generating autoloads for %s...done" file))
|
(message "Generating autoloads for %s...done" file))
|
||||||
(or visited
|
(or visited
|
||||||
;; We created this buffer, so we should kill it.
|
;; We created this buffer, so we should kill it.
|
||||||
(kill-buffer (current-buffer))))
|
(kill-buffer (current-buffer))))
|
||||||
(not done-any)))
|
(not output-start)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun update-file-autoloads (file &optional save-after)
|
(defun update-file-autoloads (file &optional save-after)
|
||||||
|
|
@ -467,13 +466,13 @@ to call it from a dummy buffer if FILE is not currently visited."
|
||||||
;; Check if it is up to date.
|
;; Check if it is up to date.
|
||||||
(let ((begin (match-beginning 0))
|
(let ((begin (match-beginning 0))
|
||||||
(last-time (nth 4 form))
|
(last-time (nth 4 form))
|
||||||
(file-time (nth 5 (file-attributes file))))
|
(file-time (nth 5 (file-attributes file))))
|
||||||
(if (and (or (null existing-buffer)
|
(if (and (or (null existing-buffer)
|
||||||
(not (buffer-modified-p existing-buffer)))
|
(not (buffer-modified-p existing-buffer)))
|
||||||
(listp last-time) (= (length last-time) 2)
|
(listp last-time) (= (length last-time) 2)
|
||||||
(not (time-less-p last-time file-time)))
|
(not (time-less-p last-time file-time)))
|
||||||
(throw 'up-to-date nil)
|
(throw 'up-to-date nil)
|
||||||
(autoload-remove-section (match-beginning 0))
|
(autoload-remove-section begin)
|
||||||
(setq found t))))
|
(setq found t))))
|
||||||
((string< load-name (nth 2 form))
|
((string< load-name (nth 2 form))
|
||||||
;; We've come to a section alphabetically later than
|
;; We've come to a section alphabetically later than
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue