From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Removing unloaded functions from auto-mode-alist. Date: Wed, 20 Apr 2005 00:33:36 +0200 Message-ID: <85oecagzwf.fsf@lola.goethe.zz> References: <87zmvu6ba2.fsf@xs4all.nl> <85ll7e68ei.fsf@lola.goethe.zz> <854qe2ihhi.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 1114034881 6524 80.91.229.2 (20 Apr 2005 22:08:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 20 Apr 2005 22:08:01 +0000 (UTC) Cc: Lute Kamstra , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 21 00:07:58 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DONLj-0006AR-1S for ged-emacs-devel@m.gmane.org; Thu, 21 Apr 2005 00:07:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DONQJ-0008SG-7e for ged-emacs-devel@m.gmane.org; Wed, 20 Apr 2005 18:11:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DOM6f-00037Q-Jy for emacs-devel@gnu.org; Wed, 20 Apr 2005 16:47:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DOM6e-00036Z-9M for emacs-devel@gnu.org; Wed, 20 Apr 2005 16:47:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DOM6e-000740-0P for emacs-devel@gnu.org; Wed, 20 Apr 2005 16:47:32 -0400 Original-Received: from [151.189.21.44] (helo=mail-in-04.arcor-online.net) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DOLr5-0007R4-6d for emacs-devel@gnu.org; Wed, 20 Apr 2005 16:31:27 -0400 Original-Received: from lola.goethe.zz (i53879BBD.versanet.de [83.135.155.189]) by mail-in-04.arcor-online.net (Postfix) with ESMTP id 83040104D14; Wed, 20 Apr 2005 20:14:00 +0200 (CEST) Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 1D9881C1E25E; Wed, 20 Apr 2005 00:33:36 +0200 (CEST) Original-To: Stefan Monnier In-Reply-To: (Stefan Monnier's message of "Tue, 19 Apr 2005 17:58:34 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:36197 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36197 Stefan Monnier writes: >> Forget it, Bub. TeX-mode and LaTeX-mode are already taken as >> aliases. Who was the smart guy responsible for that? The >> annotations show: > >> 1.3 (jimb 13-May-91): ;;;###autoload >> 1.17 (eric 23-Apr-93): (defalias 'TeX-mode 'tex-mode) >> 1.3 (jimb 13-May-91): ;;;###autoload >> 1.99 (rms 16-Feb-99): (defalias 'plain-TeX-mode 'plain-tex-mode) >> 1.99 (rms 16-Feb-99): ;;;###autoload >> 1.17 (eric 23-Apr-93): (defalias 'LaTeX-mode 'latex-mode) >> 1.1 (root 28-Aug-90): > > Duh, this sucks! > Any objection to removing those aliases? Not here. > These names belong to AUCTeX and are just wrong in tex-mode.el. Well, that is my opinion, too. > [ In the text below, I'll asume we remove those atrocities ] I guess that they make handling the case where somebody has put mode: LaTeX in his local variable section easier. When the text then gets edited by somebody without AUCTeX. AUCTeX itself uses 'latex-mode in major-mode, and consequently also stores that in the mode variable when it writes out local variables. >>> - make a `auctex-override.el' file which does: >>> >>> (defalias 'tex-mode 'TeX-mode) >>> (defalias 'latex-mode 'LaTeX-mode) >>> ... >>> (provide 'auctex-override.el) >>> >>> Then (require 'auctex-override) makes AUCTeX the default, and hopefully an >>> (unload-feature 'auctex-override) will restore the default autloads for the >>> other tex-mode. > >> 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. 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? > 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. >>> Completely untested, of course. >> >> Unfortunately, I tested this already. That's why I had to come up >> with a better scheme. Not "better" as in "nicer", but in "reckless >> enough to stand a chance of attaining its goal". > > I'd rather try and make my suggestion work than to follow down your > insane path. > > I.e. we should remove those atrocities in tex-mode.el 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. > 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. > 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. > ;; Give preference to our > (defalias 'tex-mode 'TeX-mode) > ... > > Then users/admins can (require 'auctex-override) to make AUCTeX be > the default, and if the admin made it the default, users can > (unload-feature 'auctex-override) to make the other tex-mode be the > default. > > Of course, you can name this file something else than > `auctex-override'. > > It seems much less insane than your current code. WDYT? 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. Anyway, I spent about a day fixing this approach. For example, the first version had just (read) in it instead of (read (current-buffer)). That was fine, until I ran the batch byte compiler for the first time... I guess I don't have the nerve just now to go for another approach that would need extensive testing again. The current approach works under HEAD, 21.3 and XEmacs-21.17 or something. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum