From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Lennart Borgman" Newsgroups: gmane.emacs.devel Subject: Autoloading of defcustoms etc Date: Thu, 6 Jan 2005 21:10:15 +0100 Message-ID: <002a01c4f42b$c5374000$0200a8c0@sedrcw11488> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0027_01C4F434.1E33BB40" X-Trace: sea.gmane.org 1105042384 2765 80.91.229.6 (6 Jan 2005 20:13:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 Jan 2005 20:13:04 +0000 (UTC) Cc: Per Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 06 21:12:49 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Cme00-0000NT-00 for ; Thu, 06 Jan 2005 21:12:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CmeBJ-0001Kh-W1 for ged-emacs-devel@m.gmane.org; Thu, 06 Jan 2005 15:24:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CmeB8-0001JX-QB for emacs-devel@gnu.org; Thu, 06 Jan 2005 15:24:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CmeB6-0001IR-EU for emacs-devel@gnu.org; Thu, 06 Jan 2005 15:24:16 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CmeB6-0001Hn-3e for emacs-devel@gnu.org; Thu, 06 Jan 2005 15:24:16 -0500 Original-Received: from [81.228.9.111] (helo=av4-1-sn3.vrr.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CmdyE-0004hB-1K for emacs-devel@gnu.org; Thu, 06 Jan 2005 15:10:58 -0500 Original-Received: by av4-1-sn3.vrr.skanova.net (Postfix, from userid 502) id 21CF237F07; Thu, 6 Jan 2005 21:10:57 +0100 (CET) Original-Received: from smtp1-2-sn3.vrr.skanova.net (smtp1-2-sn3.vrr.skanova.net [81.228.9.178]) by av4-1-sn3.vrr.skanova.net (Postfix) with ESMTP id D444637EC8; Thu, 6 Jan 2005 21:10:56 +0100 (CET) Original-Received: from sedrcw11488 (t5o58p74.telia.com [195.67.196.74]) by smtp1-2-sn3.vrr.skanova.net (Postfix) with SMTP id 11D1838012; Thu, 6 Jan 2005 21:10:54 +0100 (CET) Original-To: "Emacs Devel" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:31970 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31970 This is a multi-part message in MIME format. ------=_NextPart_000_0027_01C4F434.1E33BB40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > It is a generic problem that customize variables are only visible when > a package is loaded. It should be fixed, but for all variables, not > by adding autoloads for individual variables. Per A wrote this in another thread. I have taken a look at this and got helpful feedback from Per. My suggestion is that autoload.el autoloads all defcustom, define-minor-mode, defface and defgroup whether they are marked for autoloading or not. I have attached a simple change for generate-file-autoloads that does this. (Unfortunately this is for Emacs 21.3.1 which is what I am currently using, but I guess you can get the idea.) When doing this it may also be important that custom GUI warns before loading a package. Has this been taking care of already perhaps? Another important thing is perhaps that the user is warned if customized variable is saved but will not be used (because it does not require its package and that package was not loaded when customize accessed the symbol)? - Lennart ------=_NextPart_000_0027_01C4F434.1E33BB40 Content-Type: application/octet-stream; name="autoload-fix.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="autoload-fix.el" ;;; ********* THIS IS FOR EMACS 21.3.1 = ************************************** (defun generate-file-autoloads (file) "Insert at point a loaddefs autoload section for FILE. 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." (interactive "fGenerate autoloads for file: ") (let ((outbuf (current-buffer)) (autoloads-done '()) (load-name (let ((name (file-name-nondirectory file))) (if (string-match "\\.elc?$" name) (substring name 0 (match-beginning 0)) name))) (print-length nil) (print-readably t) ; This does something in Lucid Emacs. (float-output-format nil) (done-any nil) (visited (get-file-buffer file)) output-end) ;; If the autoload section we create here uses an absolute ;; pathname 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=3D dir-truename (substring source-truename 0 len))) (setq file (substring source-truename len)))) (message "Generating autoloads for %s..." file) (save-excursion (unwind-protect (progn (if visited (set-buffer visited) ;; It is faster to avoid visiting the file. (set-buffer (get-buffer-create " *generate-autoload-file*")) (kill-all-local-variables) (erase-buffer) (setq buffer-undo-list t buffer-read-only nil) (emacs-lisp-mode) (insert-file-contents file nil)) (save-excursion (save-restriction (let ((regexp (regexp-opt=20 (list (regexp-quote "(defcustom ") (regexp-quote "(define-minor-mode ") (regexp-quote generate-autoload-cookie) ) ) )) (widen) (goto-char (point-min)) (while (not (eobp)) (skip-chars-forward " \t\n\f") (cond ;;; ((looking-at (regexp-quote generate-autoload-cookie)) ;;; (search-forward generate-autoload-cookie) ((looking-at regexp) (if (looking-at (regexp-quote generate-autoload-cookie)) (progn (search-forward generate-autoload-cookie) (skip-chars-forward " \t")) (while (not (eolp)) (backward-char))) (unless (eolp) (error "not eolp")) (setq done-any t) (if (eolp) ;; Read the next form and make an autoload. (let* ((form (prog1 (read (current-buffer)) (or (bolp) (forward-line 1)))) (autoload (make-autoload form load-name))) ;;(message "form=3D%s" (pp-to-string form)) (sleep-for 5) (if autoload (setq autoloads-done (cons (nth 1 form) autoloads-done)) (setq autoload form)) (autoload-print-form autoload)) =20 ;; Copy the rest of the line to the output. (princ (buffer-substring (progn ;; Back up over whitespace, to preserve it. (skip-chars-backward " \f\t") (if (=3D (char-after (1+ (point))) ? ) ;; Eat one space. (forward-char 1)) (point)) (progn (forward-line 1) (point))) outbuf))) ((looking-at ";") ;; Don't read the comment. (forward-line 1)) (t (forward-sexp 1) (forward-line 1)))))))) (or visited ;; We created this buffer, so we should kill it. (kill-buffer (current-buffer))) (set-buffer outbuf) (setq output-end (point-marker)))) (if done-any (progn ;; Insert the section-header line ;; which lists the file name and which functions are in it, etc. (insert generate-autoload-section-header) (prin1 (list 'autoloads autoloads-done load-name (autoload-trim-file-name file) (nth 5 (file-attributes file))) outbuf) (terpri outbuf) ;; Break that line at spaces, to avoid very long lines. ;; Make each sub-line into a comment. (with-current-buffer outbuf (save-excursion (forward-line -1) (while (not (eolp)) (move-to-column 64) (skip-chars-forward "^ \n") (or (eolp) (insert "\n" generate-autoload-section-continuation))))) (insert ";;; Generated autoloads from " (autoload-trim-file-name file) "\n") (goto-char output-end) (insert generate-autoload-section-trailer))) (message "Generating autoloads for %s...done" file))) ------=_NextPart_000_0027_01C4F434.1E33BB40 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_NextPart_000_0027_01C4F434.1E33BB40--