From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Removing unloaded functions from auto-mode-alist. Date: Wed, 20 Apr 2005 14:52:20 -0400 Message-ID: References: <87zmvu6ba2.fsf@xs4all.nl> <85ll7e68ei.fsf@lola.goethe.zz> <854qe2ihhi.fsf@lola.goethe.zz> <85oecagzwf.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1114023249 30122 80.91.229.2 (20 Apr 2005 18:54:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 20 Apr 2005 18:54:09 +0000 (UTC) Cc: Lute Kamstra , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 20 20:54:07 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DOKKR-0001mq-S0 for ged-emacs-devel@m.gmane.org; Wed, 20 Apr 2005 20:53:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DOKP0-0008NH-GP for ged-emacs-devel@m.gmane.org; Wed, 20 Apr 2005 14:58:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DOKOS-00083Y-8y for emacs-devel@gnu.org; Wed, 20 Apr 2005 14:57:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DOKOQ-00082a-Mw for emacs-devel@gnu.org; Wed, 20 Apr 2005 14:57:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DOKOQ-0007f4-FM for emacs-devel@gnu.org; Wed, 20 Apr 2005 14:57:46 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DOKLX-0001BT-Dh; Wed, 20 Apr 2005 14:54:47 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 2CD3A340004; Wed, 20 Apr 2005 14:52:27 -0400 (EDT) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 2E96A4AC265; Wed, 20 Apr 2005 14:52:21 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 1389EE6C1B; Wed, 20 Apr 2005 14:52:21 -0400 (EDT) Original-To: David Kastrup In-Reply-To: <85oecagzwf.fsf@lola.goethe.zz> (David Kastrup's message of "Wed, 20 Apr 2005 00:33:36 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-4.836, requis 5, autolearn=not spam, AWL 0.06, BAYES_00 -4.90) X-MailScanner-From: monnier@iro.umontreal.ca 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: news.gmane.org gmane.emacs.devel:36183 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36183 >>> Won't work. Autoloads corresponding to a different file than the >>> loaded one don't get restored. >> That's a bug which we should fix. > I am not sure it is a bug. Maybe not the problem described in the text I quoted, but if I have function FOO autoloaded and (require 'blabla) replaces that with some other definition, than an immediately following (unload-feature 'blabla) should restore the autoload, no matter whether the autoload was pointing to blabla.el or not. > If I load several packages redefining one symbol, and then unload _one_ of > those packages, is it a good idea if the symbol gets restored to > an autoload? That's a different scenario. We'll cross that bridge when we get there. >> In the mean time, you can use an auctex-override-unload-hook to >> re-install the autoloads. > This hook is not available in XEmacs or in Emacs 21.3. And the normal > auctex-unload-hook is getting run before symbols are fmakunbound, so > can't restore the autoloads permanently. As mentioned in another email, if you define with `fset' instead of `defalias', the modification is not recorded, so the unload won't do any `fmakunbound'. > It won't change that AUCTeX has to redefine tex-mode and latex-mode in > order to be a useful default mode, and that this needs to get reverted > by unload-feature. Of course. >> and we should fix the unload-feature to properly re-install >> autoloads. > I am not sure that reinstalling some old autoloads from some previous > time is "proper" here. Can't be much worse than leaving those functions undefined, can it? >> In the mean time, you should be able make my suggestion work by using the >> following autoload-override.el file: >> >> ;; Override the atrocities in tex-mode.el. >> (fmakunbound 'TeX-mode) >> (autoload 'TeX-mode "...") >> ... >> >> (defvar TeX-saved-other-tex-autoloads >> (mapcar (lambda (f) (cons f (symbol-function f))) >> '(tex-mode latex-mode ...))) >> >> (add-hook 'auctex-override-unload-hook >> (lambda () >> (dolist (x TeX-saved-other-tex-autoloads) >> (fset (car x) (cdr x))))) > Works only in Emacs 22. We'll talk about that solution in four years > or so. It should be adaptable to other emacsen. > I just remembered another reason for my insane approach: it gives me > working function documentation in the generated autoloads. Manual > autoloads don't give me that, and the string replacements in the DOC > string previously required using TeX-defun instead of just defun, and > that means manual autoloads. My suggestion uses plain `defun' and normal auto-generated autoloads. It concentrates all the icky bits in one file which does nothing else than the icky bits of dealing with the conflict between AUCTeX and tex-mode on the few toplevel functions like `tex-mode', `latex-mode', `texinfo-mode', and `doctex-mode'. Stefan