On Tue, 2002-11-05 at 02:14, Martin Stjernholm wrote:
Ville Skyttä <scop(a)xemacs.org> wrote:
> > A fix for this would be to append the new entries to the end of
> > auto-mode-alist instead, e.g:
> >
> > ;;;###autoload
> > (add-to-list 'auto-mode-alist '("\\.m\\'" .
objc-mode) t)
> >
> > This will work with Emacs 21 and XEmacs in the cvs since add-to-list
> > has gotten the third APPEND argument there. To make it work with older
> > (X)Emacsen, the package maintainer can add something like this:
/.../
> Yep, you're right, the APPEND argument would be better, unfortunately it
> cannot be used in XEmacs packages at the moment because of the backwards
> compatibility stuff you already mentioned. And I wouldn't like to see
> too big workarounds for this in every package.
That is the workaround I intended to have in CC Mode. Why can't it be
used?
It can, but doing that in CC Mode doesn't help the N other packages out
there. I'm looking for a solution that would need to be done once, and
which would work for all of them.
Is there some situation where loaddefs.el in older XEmacsen are
updated with newer packages?
Not the file itself.
(The size and ugliness of the kludge
itself doesn't become me very much; CC Mode already has plenty more of
similar cruft to work around bugs and limitations in various
versions. This one hardly makes a dent.)
Yes, but I'm just wondering if it wouldn't have to be that way for this
particular case.
> /.../ Or we could try to make sure these *-mode-alist
associations
> are only used for generating package autoloads, and not evaluated
> when loading the file. I don't know how to do that, though. Ideas?
>From the elisp manual:
/.../ You can also use a magic comment to execute a form at build
time *without* executing it when the file itself is loaded. To do
this, write the form *on the same line* as the magic comment.
Since it is in a comment, it does nothing when you load the source
file; but `update-file-autoloads' copies it to `loaddefs.el',
where it is executed while building Emacs. /.../
Ah, thanks! But this clearly needs clarification regarding packages;
autoloads in packages are *not* copied to loaddefs.el, but into a
package-specific auto-autoloads.el. And autoloads in packages have
nothing to do with building XEmacs.
Thus an alternative could be something like this:
(defun c-append-to-auto-mode-alist (element)
(unless (member element auto-mode-alist)
(setq auto-mode-alist (nconc auto-mode-alist (list element)))))
/.../
;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" .
objc-mode))
(c-append-to-auto-mode-alist '("\\.m\\'" . objc-mode))
That looks kinda better to me.
But that would duplicate all the entries in the source, which
I'd
rather avoid. One might of course skip the second step; it'd work
equally well as in earlier versions, when the package relied on the
central auto-mode-alist value. But I rather liked the idea to update
auto-mode-alist on package load, to install bindings for new modes
that doesn't exist in older (X)Emacsen.
I'm not sure if I understand you correctly now, but the autoload cookies
in packages are used for that. Autoloads generated from packages stay
in packages and are installed with them. And modes in packages don't
"exist in" any XEmacsen (>= 21.1). That's why it makes no sense to have
a central auto-mode-alist in core containing entries for modes that
don't necessarily exist.
Given this, I don't see a reason why doing just a
;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" .
objc-mode))
...wouldn't solve the problem (ie. the only change to the current
situation being that the list wouldn't be updated on mode load time).
--
\/ille Skyttä
scop at
xemacs.org