[Top][All Lists]

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

Re: emacs packages

From: Federico Beffa
Subject: Re: emacs packages
Date: Wed, 17 Jun 2015 09:42:44 +0200

On Tue, Jun 16, 2015 at 6:00 PM, Ludovic Courtès <address@hidden> wrote:
>> - An ELPA package importer
>> - An 'emacs-build-system'
> Sounds very useful to me!

Thanks for the interest!

>> 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,
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.

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.


reply via email to

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