unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Cc: Lute Kamstra <Lute.Kamstra.lists@xs4all.nl>, emacs-devel@gnu.org
Subject: Re: Removing unloaded functions from auto-mode-alist.
Date: Wed, 20 Apr 2005 00:33:36 +0200	[thread overview]
Message-ID: <85oecagzwf.fsf@lola.goethe.zz> (raw)
In-Reply-To: <jwv1x96v40w.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 19 Apr 2005 17:58:34 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> 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

  reply	other threads:[~2005-04-19 22:33 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-19 15:23 Removing unloaded functions from auto-mode-alist Lute Kamstra
2005-04-19 16:25 ` David Kastrup
2005-04-19 17:44   ` Stefan Monnier
2005-04-19 21:28     ` David Kastrup
2005-04-19 21:58       ` Stefan Monnier
2005-04-19 22:33         ` David Kastrup [this message]
2005-04-20 18:52           ` Stefan Monnier
2005-04-24 20:24             ` Lute Kamstra
2005-04-24 20:50               ` David Kastrup
2005-04-24 21:51                 ` Lute Kamstra
2005-04-24 22:00                   ` David Kastrup
2005-04-24 23:37                     ` Lute Kamstra
2005-04-25  0:07                       ` David Kastrup
2005-04-26 10:04                       ` Richard Stallman
2005-04-20 19:22           ` Lute Kamstra
2005-04-19 23:01         ` Stefan Monnier
2005-04-19 23:14         ` Lute Kamstra
2005-04-19 23:24           ` David Kastrup
2005-04-20 18:41             ` Stefan Monnier
2005-04-20 19:00               ` David Kastrup
2005-04-20 19:18                 ` Stefan Monnier
2005-04-20 19:50                   ` David Kastrup
2005-04-20 19:29               ` Lute Kamstra
2005-04-20 14:57           ` Richard Stallman
2005-04-20 15:59             ` Lute Kamstra
2005-04-21 15:30               ` Richard Stallman
2005-04-21 16:35                 ` Lute Kamstra
2005-04-22 20:51                   ` David Kastrup
2005-04-23 21:00                     ` Lute Kamstra
2005-04-23 22:10                       ` David Kastrup
2005-04-24 20:21                         ` Lute Kamstra
2005-04-24 20:32                           ` David Kastrup
2005-04-24 20:52                             ` Lute Kamstra
2005-04-25 16:05                             ` Richard Stallman
2005-04-23 22:24                     ` Richard Stallman
2005-04-20 14:57         ` Richard Stallman
2005-04-20 15:02           ` Stefan Monnier
2005-04-20 15:57             ` David Kastrup
2005-04-20 18:37               ` Stefan Monnier
2005-04-20 19:19                 ` David Kastrup
2005-04-20 20:11                   ` Stefan Monnier
2005-04-20 20:25                     ` David Kastrup
2005-04-20 20:57                       ` Stefan Monnier
2005-04-20 21:33                         ` David Kastrup
2005-04-20 16:25             ` Andreas Schwab
2005-04-20 16:57               ` David Kastrup
2005-04-20 22:47                 ` Andreas Schwab
2005-04-20 22:58                   ` David Kastrup
2005-04-21  9:56                     ` Andreas Schwab
2005-04-21 10:12                       ` David Kastrup
2005-04-21 11:50                         ` Andreas Schwab
2005-04-21 19:56                         ` Richard Stallman
2005-04-21 20:13                           ` David Kastrup
2005-04-23 16:15                             ` Richard Stallman
2005-04-23 16:23                               ` David Kastrup
2005-04-23 16:15                           ` Richard Stallman
2005-04-21 11:41                       ` Johan Vromans
2005-04-20 15:43           ` David Kastrup
2005-04-21 15:30             ` Richard Stallman
2005-04-21 17:46               ` David Kastrup
2005-04-23 16:15                 ` Richard Stallman
2005-04-19 22:00       ` Lute Kamstra
2005-04-19 23:22       ` Andreas Schwab
2005-04-19 23:33         ` David Kastrup
2005-04-19 21:05   ` Lute Kamstra
2005-04-20 14:57     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85oecagzwf.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=Lute.Kamstra.lists@xs4all.nl \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).