comparison lisp/autoload.el @ 528:ef4d2466a29c

[xemacs-hg @ 2001-05-10 09:59:45 by ben] implement user-name-all-completions under Windows. xemacs.mak: need another lib (netapi32.lib) for user-name-all-completions. emacs.c: create new function force-debugging-signal (only when DEBUG_XEMACS) to breakpoint or abort to the debugger. mule\mule-coding.el, file-coding.c, file-coding.h, lisp.h: move coding-system-charset to lisp to avoid doc warning. autoload.el, packages.el, startup.el, update-elc-2.el, update-elc.el: Rewrite much of the bootstrapping process to be more robust, and in particular to rebuild the auto-autoloads and custom-loads files no matter what state (including missing) they're currently in. xemacs.mak: remove autoload-building target. Makefile.in.in: remove autoload targets.
author ben
date Thu, 10 May 2001 09:59:57 +0000
parents 223736d75acb
children 666d73d6ac56
comparison
equal deleted inserted replaced
527:7b35ad872326 528:ef4d2466a29c
466 (defun update-autoloads-from-directory (dir) 466 (defun update-autoloads-from-directory (dir)
467 "Update `generated-autoload-file' with all the current autoloads from DIR. 467 "Update `generated-autoload-file' with all the current autoloads from DIR.
468 This runs `update-file-autoloads' on each .el file in DIR. 468 This runs `update-file-autoloads' on each .el file in DIR.
469 Obsolete autoload entries for files that no longer exist are deleted. 469 Obsolete autoload entries for files that no longer exist are deleted.
470 Note that, if this function is called from `batch-update-directory', 470 Note that, if this function is called from `batch-update-directory',
471 `generated-autoload-file' was rebound in that function." 471 `generated-autoload-file' was rebound in that function.
472
473 You don't really want to be calling this function. Try using
474 `update-autoload-files' instead."
472 (interactive "DUpdate autoloads for directory: ") 475 (interactive "DUpdate autoloads for directory: ")
473 (setq dir (expand-file-name dir)) 476 (setq dir (expand-file-name dir))
474 (let ((simple-dir (file-name-as-directory 477 (let ((simple-dir (file-name-as-directory
475 (file-name-nondirectory 478 (file-name-nondirectory
476 (directory-file-name dir)))) 479 (directory-file-name dir))))
496 ;; Update or create autoload sections for existing files. 499 ;; Update or create autoload sections for existing files.
497 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$")) 500 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$"))
498 (unless noninteractive 501 (unless noninteractive
499 (save-buffer))))) 502 (save-buffer)))))
500 503
501 ;;;###autoload
502 (defun batch-update-autoloads ()
503 "Update the autoloads for the files or directories on the command line.
504 Runs `update-file-autoloads' on files and `update-directory-autoloads'
505 on directories. Must be used only with -batch, and kills Emacs on completion.
506 Each file will be processed even if an error occurred previously.
507 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'.
508 The directory to which the auto-autoloads.el file must be the first parameter
509 on the command line."
510 (unless noninteractive
511 (error "batch-update-autoloads is to be used only with -batch"))
512 (let ((defdir default-directory)
513 (enable-local-eval nil)) ; Don't query in batch mode.
514 ;; (message "Updating autoloads in %s..." generated-autoload-file)
515 (dolist (arg command-line-args-left)
516 (setq arg (expand-file-name arg defdir))
517 (cond
518 ((file-directory-p arg)
519 (message "Updating autoloads for directory %s..." arg)
520 (update-autoloads-from-directory arg))
521 ((file-exists-p arg)
522 (update-file-autoloads arg))
523 (t (error "No such file or directory: %s" arg))))
524 (fixup-autoload-buffer (concat (if autoload-package-name
525 autoload-package-name
526 (file-name-nondirectory defdir))
527 "-autoloads"))
528 (save-some-buffers t)
529 ;; (message "Done")
530 (kill-emacs 0)))
531
532 (defun fixup-autoload-buffer (sym) 504 (defun fixup-autoload-buffer (sym)
533 (save-excursion 505 (save-excursion
534 (set-buffer (find-file-noselect generated-autoload-file)) 506 (set-buffer (find-file-noselect generated-autoload-file))
535 (goto-char (point-min)) 507 (goto-char (point-min))
536 (if (and (not (= (point-min) (point-max))) 508 (if (and (not (= (point-min) (point-max)))
542 (goto-char (point-max)) 514 (goto-char (point-max))
543 (insert "\n(provide '" sym ")\n"))))) 515 (insert "\n(provide '" sym ")\n")))))
544 516
545 (defvar autoload-package-name nil) 517 (defvar autoload-package-name nil)
546 518
547 ;; #### this function is almost identical to, but subtly different from, 519 ;;;###autoload
548 ;; batch-update-autoloads. Both of these functions, unfortunately, are 520 (defun update-autoload-files (files-or-dirs &optional all-into-one-file force)
549 ;; used in various build scripts in xemacs-packages. They should be 521 "Update all the autoload files associated with FILES-OR-DIRS.
550 ;; merged. (However, it looks like no scripts pass more than one arg, 522 FILES-OR-DIRS should be a list of files or directories to be
551 ;; making merging easy.) --ben 523 processed. If ALL-INTO-ONE-FILE is not given, the appropriate
524 autoload file for each file or directory (located in that directory,
525 or in the directory of the specified file) will be updated with the
526 directory's or file's autoloads, some additional fixup text will be
527 added, and the files will be saved. If ALL-INTO-ONE-FILE is given,
528 `generated-autoload-file' should be set to the name of the autoload
529 file into which the autoloads will be generated, and the autoloads
530 for all files and directories will go into that same file.
531
532 If FORCE is non-nil, always save out the autoload files even if unchanged."
533 (let ((defdir default-directory)
534 (enable-local-eval nil)) ; Don't query in batch mode.
535 ;; (message "Updating autoloads in %s..." generated-autoload-file)
536 (dolist (arg files-or-dirs)
537 (setq arg (expand-file-name arg defdir))
538 (let ((generated-autoload-file
539 (if all-into-one-file generated-autoload-file
540 (expand-file-name autoload-file-name
541 (if (file-directory-p arg) arg
542 (file-name-directory arg))))))
543 (cond
544 ((file-directory-p arg)
545 (message "Updating autoloads for directory %s..." arg)
546 (update-autoloads-from-directory arg))
547 ((file-exists-p arg)
548 (update-file-autoloads arg))
549 (t (error "No such file or directory: %s" arg)))
550 (when (not all-into-one-file)
551 (fixup-autoload-buffer (concat (if autoload-package-name
552 autoload-package-name
553 (file-name-nondirectory defdir))
554 "-autoloads"))
555 (if force (set-buffer-modified-p
556 t (find-file-noselect generated-autoload-file))))))
557 (when all-into-one-file
558 (fixup-autoload-buffer (concat (if autoload-package-name
559 autoload-package-name
560 (file-name-nondirectory defdir))
561 "-autoloads"))
562 (if force (set-buffer-modified-p
563 t (find-file-noselect generated-autoload-file))))
564 (save-some-buffers t)
565 ;; (message "Done")
566 ))
567
568 ;; #### these entry points below are a big mess, especially the
569 ;; first two. there don't seem to be very many packages that use the
570 ;; first one (the "all-into-one-file" variety), and do they actually
571 ;; rely on this functionality? --ben
572
573 ;;;###autoload
574 (defun batch-update-autoloads ()
575 "Update the autoloads for the files or directories on the command line.
576 Runs `update-file-autoloads' on files and `update-directory-autoloads'
577 on directories. Must be used only with -batch, and kills Emacs on completion.
578 Each file will be processed even if an error occurred previously.
579 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'.
580 The directory to which the auto-autoloads.el file must be the first parameter
581 on the command line."
582 (unless noninteractive
583 (error "batch-update-autoloads is to be used only with -batch"))
584 (update-autoload-files command-line-args-left t)
585 (kill-emacs 0))
552 586
553 ;;;###autoload 587 ;;;###autoload
554 (defun batch-update-directory () 588 (defun batch-update-directory ()
555 "Update the autoloads for the directories on the command line. 589 "Update the autoloads for the directories on the command line.
556 Runs `update-file-autoloads' on each file in the given directory, and must 590 Runs `update-file-autoloads' on each file in the given directory, and must
557 be used only with -batch." 591 be used only with -batch."
558 (unless noninteractive 592 (unless noninteractive
559 (error "batch-update-directory is to be used only with -batch")) 593 (error "batch-update-directory is to be used only with -batch"))
560 (let ((defdir default-directory) 594 (update-autoload-files command-line-args-left)
561 (enable-local-eval nil)) ; Don't query in batch mode. 595 ;; (kill-emacs 0)
562 (dolist (arg command-line-args-left) 596 (setq command-line-args-left nil))
563 (setq arg (expand-file-name arg defdir))
564 (let ((generated-autoload-file (expand-file-name autoload-file-name
565 arg)))
566 (cond
567 ((file-directory-p arg)
568 (message "Updating autoloads in directory %s..." arg)
569 (update-autoloads-from-directory arg))
570 (t (error "No such file or directory: %s" arg)))
571 (fixup-autoload-buffer (concat (if autoload-package-name
572 autoload-package-name
573 (file-name-nondirectory arg))
574 "-autoloads"))
575 (save-some-buffers t))
576 ;; (message "Done")
577 ;; (kill-emacs 0)
578 )
579 (setq command-line-args-left nil)))
580
581 ;; #### i created the following. this one and the last should be merged into
582 ;; batch-update-autoloads and batch-update-one-directory. --ben
583 597
584 ;;;###autoload 598 ;;;###autoload
585 (defun batch-update-one-directory () 599 (defun batch-update-one-directory ()
586 "Update the autoloads for a single directory on the command line. 600 "Update the autoloads for a single directory on the command line.
587 Runs `update-file-autoloads' on each file in the given directory, and must 601 Runs `update-file-autoloads' on each file in the given directory, and must
588 be used only with -batch." 602 be used only with -batch."
589 (unless noninteractive 603 (unless noninteractive
590 (error "batch-update-directory is to be used only with -batch")) 604 (error "batch-update-directory is to be used only with -batch"))
591 (let ((defdir default-directory) 605 (let ((arg (car command-line-args-left)))
592 (enable-local-eval nil)) ; Don't query in batch mode. 606 (setq command-line-args-left (cdr command-line-args-left))
593 (let ((arg (car command-line-args-left))) 607 (update-autoload-files (list arg))))
594 (setq command-line-args-left (cdr command-line-args-left)) 608
595 (setq arg (expand-file-name arg defdir)) 609 ;;;###autoload
596 (let ((generated-autoload-file (expand-file-name autoload-file-name 610 (defun batch-force-update-one-directory ()
597 arg))) 611 "Update the autoloads for a single directory on the command line.
598 (cond 612 Runs `update-file-autoloads' on each file in the given directory, and must
599 ((file-directory-p arg) 613 be used only with -batch. Always rewrite the autoloads file, even if
600 (message "Updating autoloads in directory %s..." arg) 614 unchanged."
601 (update-autoloads-from-directory arg)) 615 (unless noninteractive
602 (t (error "No such file or directory: %s" arg))) 616 (error "batch-update-directory is to be used only with -batch"))
603 (fixup-autoload-buffer (concat (if autoload-package-name 617 (let ((arg (car command-line-args-left)))
604 autoload-package-name 618 (setq command-line-args-left (cdr command-line-args-left))
605 (file-name-nondirectory arg)) 619 (update-autoload-files (list arg) t)))
606 "-autoloads"))
607 (save-some-buffers t))
608 ;; (message "Done")
609 )))
610 620
611 (provide 'autoload) 621 (provide 'autoload)
612 622
613 ;;; autoload.el ends here 623 ;;; autoload.el ends here