Mercurial > hg > xemacs-beta
comparison lisp/utils/autoload.el @ 32:e04119814345 r19-15b99
Import from CVS: tag r19-15b99
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:52:56 +0200 |
parents | 4103f0995bd7 |
children | d620409f5eb8 |
comparison
equal
deleted
inserted
replaced
31:b9328a10c56c | 32:e04119814345 |
---|---|
290 (t | 290 (t |
291 (forward-sexp 1) | 291 (forward-sexp 1) |
292 (forward-line 1))) | 292 (forward-line 1))) |
293 (if dofiles | 293 (if dofiles |
294 (setq funlist (cdr funlist))))))) | 294 (setq funlist (cdr funlist))))))) |
295 (unless visited | 295 ;;(unless visited |
296 ;; We created this buffer, so we should kill it. | 296 ;; We created this buffer, so we should kill it. |
297 (kill-buffer (current-buffer))) | 297 ;; Customize needs it later, we don't want to read the file |
298 ;; in twice. | |
299 ;;(kill-buffer (current-buffer))) | |
298 (set-buffer outbuf) | 300 (set-buffer outbuf) |
299 (setq output-end (point-marker)))) | 301 (setq output-end (point-marker)))) |
300 (if t ;; done-any | 302 (if t ;; done-any |
301 ;; XEmacs -- always do this so that we cache the information | 303 ;; XEmacs -- always do this so that we cache the information |
302 ;; that we've processed the file already. | 304 ;; that we've processed the file already. |
330 (expand-file-name "../lisp/prim/auto-autoloads.el" data-directory) | 332 (expand-file-name "../lisp/prim/auto-autoloads.el" data-directory) |
331 "*File `update-file-autoloads' puts autoloads into. | 333 "*File `update-file-autoloads' puts autoloads into. |
332 A .el file can set this in its local variables section to make its | 334 A .el file can set this in its local variables section to make its |
333 autoloads go somewhere else.") | 335 autoloads go somewhere else.") |
334 | 336 |
337 (defvar generated-custom-file | |
338 (expand-file-name "../lisp/prim/custom-load.el" data-directory) | |
339 "*File `update-file-autoloads' puts customization into.") | |
340 | |
341 ;; Written by Per Abrahamsen | |
342 (defun autoload-snarf-defcustom (file) | |
343 "Snarf all customizations in the current buffer." | |
344 (let ((visited (get-file-buffer file))) | |
345 (save-excursion | |
346 (set-buffer (or visited (find-file-noselect file))) | |
347 (when (and file (string-match "\\`\\(.*\\)\\.el\\'" file)) | |
348 (goto-char (point-min)) | |
349 (condition-case nil | |
350 (let ((name (file-name-nondirectory (match-string 1 file)))) | |
351 (while t | |
352 (let ((expr (read (current-buffer)))) | |
353 (when (and (listp expr) | |
354 (memq (car expr) '(defcustom defface defgroup))) | |
355 (eval expr) | |
356 (put (nth 1 expr) 'custom-where name))))) | |
357 (error nil))) | |
358 (unless (buffer-modified-p) | |
359 (kill-buffer (current-buffer)))))) | |
360 | |
335 ;;;###autoload | 361 ;;;###autoload |
336 (defun update-file-autoloads (file) | 362 (defun update-file-autoloads (file) |
337 "Update the autoloads for FILE in `generated-autoload-file' | 363 "Update the autoloads for FILE in `generated-autoload-file' |
338 \(which FILE might bind in its local variables)." | 364 \(which FILE might bind in its local variables)." |
339 (interactive "fUpdate autoloads for file: ") | 365 (interactive "fUpdate autoloads for file: ") |
368 (search-forward generate-autoload-section-trailer)) | 394 (search-forward generate-autoload-section-trailer)) |
369 (when (eq (point) (point-min)) ; No existing entries? | 395 (when (eq (point) (point-min)) ; No existing entries? |
370 (goto-char (point-max)))) ; Append. | 396 (goto-char (point-max)))) ; Append. |
371 | 397 |
372 ;; Add in new sections for file | 398 ;; Add in new sections for file |
373 (generate-file-autoloads file)) | 399 (generate-file-autoloads file) |
374 | 400 (autoload-snarf-defcustom file)) |
375 (when (interactive-p) (save-buffer)))) | 401 |
402 (when (interactive-p) (save-buffer)))) | |
376 | 403 |
377 ;;;###autoload | 404 ;;;###autoload |
378 (defun update-autoloads-here () | 405 (defun update-autoloads-here () |
379 "Update sections of the current buffer generated by `update-file-autoloads'." | 406 "Update sections of the current buffer generated by `update-file-autoloads'." |
380 (interactive) | 407 (interactive) |
456 ;; Update or create autoload sections for existing files. | 483 ;; Update or create autoload sections for existing files. |
457 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$")) | 484 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$")) |
458 (unless noninteractive | 485 (unless noninteractive |
459 (save-buffer))))) | 486 (save-buffer))))) |
460 | 487 |
488 ;; Based on code from Per Abrahamsen | |
489 (defun autoload-save-customization () | |
490 (save-excursion | |
491 (set-buffer (find-file-noselect generated-custom-file)) | |
492 (erase-buffer) | |
493 (insert | |
494 (with-output-to-string | |
495 (mapatoms (lambda (symbol) | |
496 (let ((members (get symbol 'custom-group)) | |
497 item where found) | |
498 (when members | |
499 (princ "(put '") | |
500 (princ symbol) | |
501 (princ " 'custom-loads '(") | |
502 (while members | |
503 (setq item (car (car members)) | |
504 members (cdr members) | |
505 where (get item 'custom-where)) | |
506 (unless (or (null where) | |
507 (member where found)) | |
508 (when found | |
509 (princ " ")) | |
510 (prin1 where) | |
511 (push where found))) | |
512 (princ "))\n"))))))))) | |
513 | |
461 ;;;###autoload | 514 ;;;###autoload |
462 (defun batch-update-autoloads () | 515 (defun batch-update-autoloads () |
463 "Update the autoloads for the files or directories on the command line. | 516 "Update the autoloads for the files or directories on the command line. |
464 Runs `update-file-autoloads' on files and `update-directory-autoloads' | 517 Runs `update-file-autoloads' on files and `update-directory-autoloads' |
465 on directories. Must be used only with -batch, and kills Emacs on completion. | 518 on directories. Must be used only with -batch, and kills Emacs on completion. |
477 (message "Updating autoloads for directory %s..." arg) | 530 (message "Updating autoloads for directory %s..." arg) |
478 (update-autoloads-from-directory arg)) | 531 (update-autoloads-from-directory arg)) |
479 ((file-exists-p arg) | 532 ((file-exists-p arg) |
480 (update-file-autoloads arg)) | 533 (update-file-autoloads arg)) |
481 (t (error "No such file or directory: %s" arg)))) | 534 (t (error "No such file or directory: %s" arg)))) |
535 (autoload-save-customization) | |
482 (save-some-buffers t) | 536 (save-some-buffers t) |
483 (message "Done") | 537 (message "Done") |
484 (kill-emacs 0))) | 538 (kill-emacs 0))) |
485 | 539 |
486 (provide 'autoload) | 540 (provide 'autoload) |