* [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
@ 2015-07-08 14:43 Alex Kost
2015-07-08 22:02 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Alex Kost @ 2015-07-08 14:43 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 52 bytes --]
The patch to follow Federico's elpa/emacs commits.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Find-autoloads-in-guix.d-subdirectories.patch --]
[-- Type: text/x-patch, Size: 4167 bytes --]
From 5ef9e359203a82f9394391161da9fd9dda982f46 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 19 Jun 2015 12:31:59 +0300
Subject: [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
Co-authored-by: Federico Beffa <beffa@fbengineering.ch>.
* 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-init.el.in: Do not add guix emacs directory to 'load-path'
because it will be done by 'guix-emacs-load-autoloads'. Move
requiring 'guix-emacs' from the top-level to a clause for checking for
'guix-package-enable-at-startup'.
---
emacs/guix-emacs.el | 29 ++++++++++++++++++++++++++---
emacs/guix-init.el.in | 4 +---
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/emacs/guix-emacs.el b/emacs/guix-emacs.el
index 512a2e2..4c3aa23 100644
--- a/emacs/guix-emacs.el
+++ b/emacs/guix-emacs.el
@@ -42,19 +42,40 @@ 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)))
;;;###autoload
(defun guix-emacs-load-autoloads (&optional all)
"Load autoloads for Emacs packages installed in a user profile.
+Add autoloads directories to `load-path'.
If ALL is nil, activate only those packages that were installed
after the last activation, otherwise activate all Emacs packages
installed in `guix-user-profile'."
@@ -65,6 +86,8 @@ installed in `guix-user-profile'."
(cl-nset-difference autoloads guix-emacs-autoloads
:test #'string=))))
(dolist (file files)
+ (cl-pushnew (file-name-directory file) load-path
+ :test #'string=)
(load file 'noerror))
(setq guix-emacs-autoloads autoloads)))
diff --git a/emacs/guix-init.el.in b/emacs/guix-init.el.in
index 4e40d71..728bc37 100644
--- a/emacs/guix-init.el.in
+++ b/emacs/guix-init.el.in
@@ -1,5 +1,4 @@
(require 'guix-autoloads)
-(require 'guix-emacs)
(defvar guix-load-path
(replace-regexp-in-string "${prefix}" "@prefix@" "@emacsuidir@")
@@ -13,9 +12,8 @@ avoid loading autoloads of Emacs packages installed in
:type 'boolean
:group 'guix)
-(add-to-list 'load-path (guix-emacs-directory))
-
(when guix-package-enable-at-startup
+ (require 'guix-emacs)
(guix-emacs-load-autoloads 'all))
(provide 'guix-init)
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
2015-07-08 14:43 [PATCH] emacs: Find autoloads in "guix.d" subdirectories Alex Kost
@ 2015-07-08 22:02 ` Ludovic Courtès
2015-07-09 7:02 ` Alex Kost
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-07-08 22:02 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> From 5ef9e359203a82f9394391161da9fd9dda982f46 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 19 Jun 2015 12:31:59 +0300
> Subject: [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
>
> Co-authored-by: Federico Beffa <beffa@fbengineering.ch>.
>
> * 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-init.el.in: Do not add guix emacs directory to 'load-path'
> because it will be done by 'guix-emacs-load-autoloads'. Move
> requiring 'guix-emacs' from the top-level to a clause for checking for
> 'guix-package-enable-at-startup'.
LGTM.
As a user, do I now need to (setq guix-package-enable-at-startup t)?
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
2015-07-08 22:02 ` Ludovic Courtès
@ 2015-07-09 7:02 ` Alex Kost
0 siblings, 0 replies; 3+ messages in thread
From: Alex Kost @ 2015-07-09 7:02 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2015-07-09 01:02 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> From 5ef9e359203a82f9394391161da9fd9dda982f46 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Fri, 19 Jun 2015 12:31:59 +0300
>> Subject: [PATCH] emacs: Find autoloads in "guix.d" subdirectories.
>>
>> Co-authored-by: Federico Beffa <beffa@fbengineering.ch>.
>>
>> * 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-init.el.in: Do not add guix emacs directory to 'load-path'
>> because it will be done by 'guix-emacs-load-autoloads'. Move
>> requiring 'guix-emacs' from the top-level to a clause for checking for
>> 'guix-package-enable-at-startup'.
>
> LGTM.
>
> As a user, do I now need to (setq guix-package-enable-at-startup t)?
No, nothing has changed here; `t' is a default value. A user need to
set it to nil if he doesn't want the emacs packages installed with guix
to be autoloaded.
--
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-09 7:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-08 14:43 [PATCH] emacs: Find autoloads in "guix.d" subdirectories Alex Kost
2015-07-08 22:02 ` Ludovic Courtès
2015-07-09 7:02 ` Alex Kost
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.