[Top][All Lists]

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

Re: emacs packages

From: Alex Kost
Subject: Re: emacs packages
Date: Wed, 17 Jun 2015 21:21:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Federico Beffa (2015-06-17 10:42 +0300) wrote:

> On Tue, Jun 16, 2015 at 6:00 PM, Ludovic Courtès <address@hidden> wrote:
>>> To make those packages automatically available in Emacs without the
>>> need for any code in the user '.emacs' file, I would suggest to
>>> include in our Emacs package site initialization file some custom code
>>> (to activate our ELPA emacs packages) such as the one in the attached
>>> 'guix-elpa.el' file.
>> guix.el already takes care of that (info "(guix) Emacs Initial Setup"),
>> so that should be enough.
> Unfortunately this doesn't work without modification. The reason is
> that I follow the emacs package.el strategy to install each ELPA
> package in it's own sub-directory. Specifically, I'm installing each
> package into ".../site-lisp/guix.d/PACKAGE-NAME-VERSION/".  The code
> in 'guix.el', however, doesn't look in sub-directories below the
> profile's '.../site-lisp'.
> Another needed detail is the fact that some package's autoload file
> (e.g., the one used by AUCTeX) includes a (require 'XXX) statement,

Ouch, what nasty things people do!

> where XXX is a library file provided by the same package. For this to
> work, I need to add the directory with the '.el' files to 'load-path'
> before loading the autoload file. Then, some package's autoload file
> add themselves to the 'load-path'. Therefore we need to remove the
> double entry.

I think double entry will do no harm, so I'm not sure if it's worth

> This is (part of) the code that I adapted from Emacs package.el to do that:
> (defun guix-package-load-all (dir)
>   "Activate all packages below DIR. (Adapted from Emacs
> 'package-activate-1' in 'package.el'.)"
>   (when (file-directory-p dir)
>     (dolist (subdir (directory-files dir))
>       (let ((pkg-dir (expand-file-name subdir dir)))
>         (when (file-directory-p pkg-dir)
>           (let* ((pkg-desc (guix-package-load-descriptor pkg-dir))
>                  (name (guix-package-desc-name pkg-desc))
>                  (pkg-file (expand-file-name
>                             (format "%s-autoloads.el" name) pkg-dir)))
>             (when (file-exists-p pkg-file)
>               ;; For some packages to be properly loaded (e.g.,
>               ;; AUCTeX), they must be on the load-path.  However,
>               ;; some packages add themselves to the load-path.  Hence
>               ;; the check to avoid duplications.
>               (push pkg-dir load-path)
>               (let ((old-lp load-path))
>                 (with-demoted-errors (load pkg-file nil t))
>                 (unless (eq old-lp load-path)
>                   (setq load-path old-lp))))))))))
> The reason for using separate sub-directory is to avoid name clashes
> (README, ...). Would be nice to adapt the code in guix.el to look into
> subdirectories as well.

The code for loading "…-autoloads.el" files is placed in
"guix-emacs.el", so perhaps it would be enough to adjust:

- 'guix-emacs-find-autoloads' to make it look at subdirs;

- 'guix-emacs-load-autoloads' to add the subdir to 'load-path' before
  loading "…-autoloads.el".

You are working on a big feature (thank you very much for that!), so
what about making "wip-emacs" (or whatever) branch for a more convenient
working on it?


reply via email to

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