From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: emacs packages Date: Fri, 19 Jun 2015 12:56:03 +0300 Message-ID: <87si9oqax8.fsf@gmail.com> References: <878ubjskwj.fsf@gnu.org> <871thatcv3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5t1u-00050w-J1 for guix-devel@gnu.org; Fri, 19 Jun 2015 05:56:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5t1p-0004Pm-CH for guix-devel@gnu.org; Fri, 19 Jun 2015 05:56:10 -0400 Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]:33010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5t1o-0004PH-MD for guix-devel@gnu.org; Fri, 19 Jun 2015 05:56:05 -0400 Received: by laka10 with SMTP id a10so70981161lak.0 for ; Fri, 19 Jun 2015 02:56:03 -0700 (PDT) In-Reply-To: (Federico Beffa's message of "Thu, 18 Jun 2015 20:32:43 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Federico Beffa Cc: Guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Federico Beffa (2015-06-18 21:32 +0300) wrote: > On Wed, Jun 17, 2015 at 8:21 PM, Alex Kost wrote: >> The code for loading "=E2=80=A6-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 "=E2=80=A6-autoloads.el". > > If you feel like wanting to adapt it yourself, please go on. I have no > experience with elisp apart from trivial things in my ./emacs. file. > > Otherwise, I will look into it. Thanks, I would like to adapt it myself. I think the attached patch should be enough to make the packages installed in "~/.guix-profile/share/emacs/site-lisp/guix.d" be properly autoloaded. I'll push this commit into "wip-emacs" when it appears, if you don't mind. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-emacs-Find-autoloads-in-guix.d-subdirectories.patch >From 7110d5d4a795f91259af37b48a2909ad9451a42d Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Fri, 19 Jun 2015 12:31:59 +0300 Subject: [PATCH] emacs: Find autoloads in "guix.d" subdirectories. Co-authored-by: Federico Beffa . * emacs/guix-emacs.el (guix-emacs-find-autoloads-in-directory, guix-emacs-subdirs): New functions. (guix-emacs-find-autoloads): Search for autoloads in "guix.d" subdirectories. (guix-emacs-load-autoloads): Add subdirectories to 'load-path'. --- emacs/guix-emacs.el | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/emacs/guix-emacs.el b/emacs/guix-emacs.el index 512a2e2..8be2f36 100644 --- a/emacs/guix-emacs.el +++ b/emacs/guix-emacs.el @@ -42,13 +42,33 @@ If PROFILE is nil, use `guix-user-profile'." (expand-file-name "share/emacs/site-lisp" (or profile guix-user-profile))) +(defun guix-emacs-find-autoloads-in-directory (directory) + "Return list of Emacs 'autoloads' files in DIRECTORY." + (directory-files directory 'full-name "-autoloads\\.el\\'" 'no-sort)) + +(defun guix-emacs-subdirs (directory) + "Return list of DIRECTORY subdirectories." + (cl-remove-if (lambda (file) + (or (string-match-p (rx "/." string-end) file) + (string-match-p (rx "/.." string-end) file) + (not (file-directory-p file)))) + (directory-files directory 'full-name nil 'no-sort))) + (defun guix-emacs-find-autoloads (&optional profile) "Return list of autoloads of Emacs packages installed in PROFILE. If PROFILE is nil, use `guix-user-profile'. Return nil if there are no emacs packages installed in PROFILE." - (let ((dir (guix-emacs-directory profile))) - (if (file-directory-p dir) - (directory-files dir 'full-name "-autoloads\\.el\\'") + (let ((elisp-root-dir (guix-emacs-directory profile))) + (if (file-directory-p elisp-root-dir) + (let ((elisp-pkgs-dir (expand-file-name "guix.d" elisp-root-dir)) + (root-autoloads (guix-emacs-find-autoloads-in-directory + elisp-root-dir))) + (if (file-directory-p elisp-pkgs-dir) + (let ((pkgs-autoloads + (cl-mapcan #'guix-emacs-find-autoloads-in-directory + (guix-emacs-subdirs elisp-pkgs-dir)))) + (append root-autoloads pkgs-autoloads)) + root-autoloads)) (message "Directory '%s' does not exist." dir) nil))) @@ -63,7 +83,10 @@ installed in `guix-user-profile'." (files (if all autoloads (cl-nset-difference autoloads guix-emacs-autoloads - :test #'string=)))) + :test #'string=))) + (dirs (mapcar #'file-name-directory files)) + (dirs (cl-remove-duplicates dirs :test #'string=))) + (setq load-path (append dirs load-path)) (dolist (file files) (load file 'noerror)) (setq guix-emacs-autoloads autoloads))) -- 2.4.2 --=-=-=--