emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing unloaded functions from auto-mode-alist.


From: David Kastrup
Subject: Re: Removing unloaded functions from auto-mode-alist.
Date: Tue, 19 Apr 2005 18:25:25 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Lute Kamstra <address@hidden> writes:

> unload-feature removes functions it is unloading from hooks.  What
> about removing these functions from auto-mode-alist as well?
>
> Index: lisp/loadhist.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/loadhist.el,v
> retrieving revision 1.32
> diff -c -r1.32 loadhist.el
> *** lisp/loadhist.el  19 Apr 2005 15:08:05 -0000      1.32
> --- lisp/loadhist.el  19 Apr 2005 15:15:19 -0000
> ***************
> *** 189,195 ****
>                       (memq x unload-feature-special-hooks))) ; Known 
> abnormal hooks etc.
>          (dolist (y unload-hook-features-list)
>            (when (eq (car-safe y) 'defun)
> !            (remove-hook x (cdr y))))))))
>       (when (fboundp 'elp-restore-function) ; remove ELP stuff first
>         (dolist (elt unload-hook-features-list)
>       (when (symbolp elt)
> --- 189,200 ----
>                       (memq x unload-feature-special-hooks))) ; Known 
> abnormal hooks etc.
>          (dolist (y unload-hook-features-list)
>            (when (eq (car-safe y) 'defun)
> !            (remove-hook x (cdr y)))))))
> !       ;; Remove any feature-symbols from auto-mode-alist as well.
> !       (dolist (elt unload-hook-features-list)
> !     (when (eq (car-safe elt) 'defun)
> !       (setq auto-mode-alist 
> !             (rassq-delete-all (cdr elt) auto-mode-alist)))))
>       (when (fboundp 'elp-restore-function) ; remove ELP stuff first
>         (dolist (elt unload-hook-features-list)
>       (when (symbolp elt)

Actually, _both_ sound like a spectacularly bad idea if the unloaded
function gets replaced by a restored autoload.  I don't know the code
well enough.

Actually, stupid question in that area: does anybody think the
following code more than duely insane?  This is at the start of a file
with generated autoloads:

(provide 'auctex)
;;;###autoload (defmacro TeX-define () (read (current-buffer)) nil)
(defmacro TeX-define ()
  (let ((form (read (current-buffer))) symbol)
    (if (stringp (nth 3 form))
        (setcar (nthcdr 3 form)
                (format (nth 3 form) "AUCTeX 11.3")))
    (if (and (eq (car form) 'autoload)
             (fboundp (setq symbol (nth 1 (nth 1 form))))
             (eq (car (symbol-function symbol)) 'autoload))
        `(progn (defalias ',symbol '(autoload ,@(nthcdr 2 form)))
                (put ',symbol 'autoload ',(cdr (symbol-function symbol))))
      form)))


And the autoloads in the original are then something like

;;;###autoload
(TeX-define)
;;;###autoload
(defun tex-mode (arg)
   "This is a function from %s"
   ...)

Here is the rationale: I want people to be able to put AUCTeX into the
TeX tree and have it preloaded.  The TeX-define autoloads are placed
before definitions that are potentially _conflicting_ with
tex-mode.el.  I want to give people the option of having AUCTeX in the
tree, and enabled by default on the site (with require 'auctex), while
people that don't like it can get rid of it of the autoloads for
AUCTeX completely with (unload-feature 'auctex).  The Doc string gets
salted with version info.

Does anybody see any problems with that approach apart from the fact
that it is crazy as anything?

The autoload cookie in the above file is just for the purpose that
somebody actually extracts autoloads from the AUCTeX tree.  In that
case, the cookie (auctex.el is conveniently alphabetically first and
gets extracted as the first package) will disable _all_ autoload
actions for such conflicting functions: they only spring into action
when (require 'auctex) is actually executed.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]