Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 71047:e98e3d0ee915
(autoload-find-file): New fun. This one calls hack-local-variables.
(generate-file-autoloads, update-file-autoloads): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 29 May 2006 02:11:27 +0000 |
parents | 35ff03ec3238 |
children | 29150c5d541b |
comparison
equal
deleted
inserted
replaced
71046:7a762d10d1a2 | 71047:e98e3d0ee915 |
---|---|
271 (move-to-column 64) | 271 (move-to-column 64) |
272 (skip-chars-forward "^ \n") | 272 (skip-chars-forward "^ \n") |
273 (or (eolp) | 273 (or (eolp) |
274 (insert "\n" generate-autoload-section-continuation)))))) | 274 (insert "\n" generate-autoload-section-continuation)))))) |
275 | 275 |
276 (defun autoload-find-file (file) | |
277 "Fetch file and put it in a temp buffer. Return the buffer." | |
278 ;; It is faster to avoid visiting the file. | |
279 (with-current-buffer (get-buffer-create " *autoload-file*") | |
280 (kill-all-local-variables) | |
281 (erase-buffer) | |
282 (setq buffer-undo-list t | |
283 buffer-read-only nil) | |
284 (emacs-lisp-mode) | |
285 (insert-file-contents file nil) | |
286 (let ((enable-local-variables :safe)) | |
287 (hack-local-variables)) | |
288 (current-buffer))) | |
289 | |
276 (defun generate-file-autoloads (file) | 290 (defun generate-file-autoloads (file) |
277 "Insert at point a loaddefs autoload section for FILE. | 291 "Insert at point a loaddefs autoload section for FILE. |
278 autoloads are generated for defuns and defmacros in FILE | 292 autoloads are generated for defuns and defmacros in FILE |
279 marked by `generate-autoload-cookie' (which see). | 293 marked by `generate-autoload-cookie' (which see). |
280 If FILE is being visited in a buffer, the contents of the buffer | 294 If FILE is being visited in a buffer, the contents of the buffer |
311 | 325 |
312 (message "Generating autoloads for %s..." file) | 326 (message "Generating autoloads for %s..." file) |
313 (save-excursion | 327 (save-excursion |
314 (unwind-protect | 328 (unwind-protect |
315 (progn | 329 (progn |
316 (if visited | 330 (set-buffer (or visited |
317 (set-buffer visited) | 331 ;; It is faster to avoid visiting the file. |
318 ;; It is faster to avoid visiting the file. | 332 (autoload-find-file file))) |
319 (set-buffer (get-buffer-create " *generate-autoload-file*")) | |
320 (kill-all-local-variables) | |
321 (erase-buffer) | |
322 (setq buffer-undo-list t | |
323 buffer-read-only nil) | |
324 (emacs-lisp-mode) | |
325 (insert-file-contents file nil)) | |
326 (save-excursion | 333 (save-excursion |
327 (save-restriction | 334 (save-restriction |
328 (widen) | 335 (widen) |
329 (goto-char (point-min)) | 336 (goto-char (point-min)) |
330 (while (not (eobp)) | 337 (while (not (eobp)) |
338 ;; Read the next form and make an autoload. | 345 ;; Read the next form and make an autoload. |
339 (let* ((form (prog1 (read (current-buffer)) | 346 (let* ((form (prog1 (read (current-buffer)) |
340 (or (bolp) (forward-line 1)))) | 347 (or (bolp) (forward-line 1)))) |
341 (autoload (make-autoload form load-name))) | 348 (autoload (make-autoload form load-name))) |
342 (if autoload | 349 (if autoload |
343 (setq autoloads-done (cons (nth 1 form) | 350 (push (nth 1 form) autoloads-done) |
344 autoloads-done)) | |
345 (setq autoload form)) | 351 (setq autoload form)) |
346 (let ((autoload-print-form-outbuf outbuf)) | 352 (let ((autoload-print-form-outbuf outbuf)) |
347 (autoload-print-form autoload))) | 353 (autoload-print-form autoload))) |
348 | 354 |
349 ;; Copy the rest of the line to the output. | 355 ;; Copy the rest of the line to the output. |
458 (search-backward "\f" nil t))) | 464 (search-backward "\f" nil t))) |
459 (or (eq found 'up-to-date) | 465 (or (eq found 'up-to-date) |
460 (and (eq found 'new) | 466 (and (eq found 'new) |
461 ;; Check that FILE has any cookies before generating a | 467 ;; Check that FILE has any cookies before generating a |
462 ;; new section for it. | 468 ;; new section for it. |
463 (save-excursion | 469 (with-current-buffer |
464 (if existing-buffer | 470 (or existing-buffer |
465 (set-buffer existing-buffer) | 471 ;; It is faster to avoid visiting the file. |
466 ;; It is faster to avoid visiting the file. | 472 (autoload-find-file file)) |
467 (set-buffer (get-buffer-create " *autoload-file*")) | 473 (save-excursion |
468 (kill-all-local-variables) | |
469 (erase-buffer) | |
470 (setq buffer-undo-list t | |
471 buffer-read-only nil) | |
472 (emacs-lisp-mode) | |
473 (insert-file-contents file nil)) | |
474 (save-excursion | |
475 (save-restriction | 474 (save-restriction |
476 (widen) | 475 (widen) |
477 (goto-char (point-min)) | 476 (goto-char (point-min)) |
478 (prog1 | 477 (prog1 |
479 (if (re-search-forward | 478 (setq no-autoloads |
480 (concat "^" (regexp-quote | 479 (not (re-search-forward |
481 generate-autoload-cookie)) | 480 (concat "^" (regexp-quote |
482 nil t) | 481 generate-autoload-cookie)) |
483 nil | 482 nil t))) |
484 (if (interactive-p) | 483 (if (and no-autoloads (interactive-p)) |
485 (message "%s has no autoloads" file)) | 484 (message "%s has no autoloads" file)) |
486 (setq no-autoloads t) | |
487 t) | |
488 (or existing-buffer | 485 (or existing-buffer |
489 (kill-buffer (current-buffer)))))))) | 486 (kill-buffer (current-buffer)))))))) |
490 (generate-file-autoloads file)))) | 487 (generate-file-autoloads file)))) |
491 (and save-after | 488 (and save-after |
492 (buffer-modified-p) | 489 (buffer-modified-p) |