emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: package.el: bytecode portability across emacs versions


From: Michael Olson
Subject: Re: package.el: bytecode portability across emacs versions
Date: Fri, 25 May 2007 21:32:14 -0400
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.0.98 (gnu/linux)

Tom Tromey <address@hidden> writes:

> I know that sharing bytecode is bad.  I just didn't know what to do
> about it.
>
> It would be pretty easy to have separate package universes depending
> on what Emacs you are running.  But that doesn't seem very
> user-friendly.  Putting the bytecode elsewhere could be done but I
> gather that this doesn't work too well in some situations.  package.el
> could re-byte-compile everything when it detects that you switched
> Emacs -- this would be fine for cases like "I upgraded my system and
> got a new Emacs", but it would be very unfriendly for other cases.
> And of course there's always "don't byte compile at all", but that
> would probably rule out installing some of the larger and more
> performance-sensitive packages.
>
> Anyway, I'm open to implementing whatever the Emacs experts agree is
> the best solution.

I would recommend doing things in the following way.

Store the byte code in subdirectories like
~/.emacs.d/elpa/emacs-22.0.98.1/.  Ensure that symlinks in that
directory exist that point to the source files in ~/.emacs/elpa/.  When
elpa is started, it should only add the proper version-specific
subdirectory to the load-path.  If under Windows, package.el would
simply copy every source file to the subdirectory rather than use a
symlink.

If package.el is run from a "new" version of Emacs/XEmacs/SXEmacs during
startup, it will display a message like "Byte-compiling ELPA packages
for <Emacs variant and version>", create the directory, copy or symlink
source files to it (also create subdirectories of symlinks/copies for
larger projects that have their own elpa subdirectory), byte compile
that directory, and add it to load-path.

Here's some code that could be used to detect the current Emacs variant
and version.  I'm just guessing about the (featurep 'sxemacs) part
because I have yet to use SXEmacs.

(defun package-get-emacs-version (&optional display-friendly)
  "Return a string that describes the current variant and version of Emacs.
If DISPLAY-FRIENDLY is non-nil, return a string that would be
useful as part of a displayed message.
Otherwise, return a string of the form \"<variant>-<version>.\""
  (let ((variant (cond ((featurep 'sxemacs) "SXEmacs")
                       ((featurep 'xemacs) "XEmacs")
                       (t "Emacs")))
        (version (cond ((featurep 'xemacs)
                        (concat (number-to-string emacs-major-version)
                                "." (number-to-string emacs-minor-version)
                                "." (number-to-string emacs-patch-level)))
                       (t emacs-version))))
    (if display-friendly
        (concat variant " " version)
      (concat (downcase variant) "-" version))))

-- 
       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
            Sysadmin -- Hobbies: Lisp, GP2X, HCoop    | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |

Attachment: pgpNzg4B0Mk2k.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]