[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: byte compiler warnings for different Emacs versions
From: |
Stefan Monnier |
Subject: |
Re: byte compiler warnings for different Emacs versions |
Date: |
Thu, 11 Nov 2004 22:41:24 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
> If I use a compile-time test and I compile on Emacs 20, then the only code
> that shows up in the .elc is the Emacs 20 version of the definition. Running
> the .elc on Emacs 21 then tries to run the Emacs 20 version, which is
> inappropriate and can result in errors.
Generally the Emacs-20 code will work fine. The problem you've shown until
now had to do with Emacs-21-specific code (i.e. the define-minor-mode) being
compiled by Emacs-20.
> I offered this file as an example to look at wrt your statement that "If a
> file byte-compiled on Emacs-20 doesn't run on Emacs-21 it's generally
> considered as a bug (but not the other way around)." Is this perhaps not
> part of your "generally" case (I guess so).
Maybe. I can't know since you don't say which specific problem you're
thinking of.
> Anyway, this is the case that I was discussing from the beginning: I would
> like a _runtime_ (top-level) test in compiled code that will make the right
> function definition based on the runtime Emacs major version.
No problem there, except that a macro (or a special form) can't be properly
byte-compiled with an Emacs that doesn't define this macro, so you can't
properly compile with Emacs-20 a piece of code that uses
`define-minor-mode'.
There's nothing Emacs-21 can do about it.
I'd recommend either you don't use define-minor-mode, or if you do, use
it unconditionally and provide your own definition of it if the Emacs
you're running on doesn't have it.
> (when (>= emacs-major-version 21)
> (define-key menu-bar-dired-operate-menu [touch]
> '(menu-item "Change Timestamp..." dired-do-touch
> :help "Change timestamp of marked files")))
As usual, (>= emacs-major-version 21) is the wrong test:
you want to use something like (fboundp 'dired-do-touch).
> I had the impression that this also worked for defun in place of define-key.
It does.
> I now think I was perhaps mistaken about that (please confirm this). And
> apparently the following does not work, in any case: (if (...)
> (define-minor-mode...) (defun...)). You say that both defun and
> define-minor-mode suffer similarly, and I guess you're right.
What I meant by `defun' suffering similarly, is that if you byte-compile
a file with an Emacs that doesn't have `defun', then the piece of
byte-compiled code that uses `defun' will never run right, even on an Emacs
that does provide `defun'. I know it's a bad example since all Emacsen
define `defun'.
> BTW, defun is referred to in Emacs 20 (via C-h f defun) as a "built-in
> function". That is why I referred to it that way. And define-key is
> referred to in both versions as a "built-in function".
I know. In Emacs-CVS (and Emacs-21.1 as well IIRC), this is fixed and
C-h f defun RET says "defun is a special form ...".
Stefan
- byte compiler warnings for different Emacs versions, Drew Adams, 2004/11/09
- Re: byte compiler warnings for different Emacs versions, Stefan Monnier, 2004/11/10
- RE: byte compiler warnings for different Emacs versions, Drew Adams, 2004/11/10
- Re: byte compiler warnings for different Emacs versions, Stefan, 2004/11/10
- RE: byte compiler warnings for different Emacs versions, Drew Adams, 2004/11/11
- Re: byte compiler warnings for different Emacs versions, Stefan Monnier, 2004/11/11
- RE: byte compiler warnings for different Emacs versions, Drew Adams, 2004/11/11
- Re: byte compiler warnings for different Emacs versions,
Stefan Monnier <=
- RE: byte compiler warnings for different Emacs versions, Drew Adams, 2004/11/12