unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile.
@ 2015-12-03 10:32 Alex Kost
  2015-12-04 14:50 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2015-12-03 10:32 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

Since a user may have several profiles, (s)he may want to load
"…-autoloads.el" files from other profiles.  So this patch provides this
possibility, i.e. if a user keeps his/her emacs packages in a separate
profile, (s)he can do something like this:

(setq guix-package-enable-at-startup nil)
(require 'guix-init nil t)
(guix-emacs-load-autoloads "/path/to/my/profile-with-emacs-packages")


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-guix-emacs-load-autoloads-takes-a-profile.patch --]
[-- Type: text/x-patch, Size: 3115 bytes --]

From 1147b16c79cb176db8f26aa88b9e930a9dea2268 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 27 Nov 2015 16:07:20 +0300
Subject: [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile.

* emacs/guix-emacs.el (guix-emacs-load-autoloads): Use 'profile'
  as an optional argument.
  (guix-emacs-load-autoloads-maybe): Adjust accordingly.
* emacs/guix-init.el: Likewise.
---
 emacs/guix-emacs.el | 31 +++++++++++++++----------------
 emacs/guix-init.el  |  2 +-
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/emacs/guix-emacs.el b/emacs/guix-emacs.el
index 0e3e8c2..04f38cb 100644
--- a/emacs/guix-emacs.el
+++ b/emacs/guix-emacs.el
@@ -74,29 +74,28 @@ Return nil if there are no emacs packages installed in PROFILE."
       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'."
-  (interactive "P")
-  (let* ((autoloads (guix-emacs-find-autoloads))
-         (files (if all
-                    autoloads
-                  (cl-nset-difference autoloads guix-emacs-autoloads
-                                      :test #'string=))))
-    (dolist (file files)
-      (cl-pushnew (file-name-directory file) load-path
+(defun guix-emacs-load-autoloads (&optional profile)
+  "Load autoloads for Emacs packages installed in PROFILE.
+If PROFILE is nil, use `guix-user-profile'.
+Add autoloads directories to `load-path'."
+  (interactive (list (guix-profile-prompt)))
+  (let* ((autoloads     (guix-emacs-find-autoloads profile))
+         (new-autoloads (cl-nset-difference autoloads
+                                            guix-emacs-autoloads
+                                            :test #'string=)))
+    (dolist (file new-autoloads)
+      (cl-pushnew (directory-file-name (file-name-directory file))
+                  load-path
                   :test #'string=)
       (load file 'noerror))
-    (setq guix-emacs-autoloads autoloads)))
+    (setq guix-emacs-autoloads
+          (append new-autoloads guix-emacs-autoloads))))
 
 (defun guix-emacs-load-autoloads-maybe ()
   "Load autoloads for Emacs packages if needed.
 See `guix-emacs-activate-after-operation' for details."
   (and guix-emacs-activate-after-operation
-       (guix-emacs-load-autoloads)))
+       (guix-emacs-load-autoloads guix-current-profile)))
 
 (provide 'guix-emacs)
 
diff --git a/emacs/guix-init.el b/emacs/guix-init.el
index 1612dee..1da6070 100644
--- a/emacs/guix-init.el
+++ b/emacs/guix-init.el
@@ -12,7 +12,7 @@ avoid loading autoloads of Emacs packages installed in
 (add-to-list 'load-path (guix-emacs-directory))
 
 (when guix-package-enable-at-startup
-  (guix-emacs-load-autoloads 'all))
+  (guix-emacs-load-autoloads))
 
 (add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe)
 (add-hook 'shell-mode-hook 'guix-build-log-minor-mode-activate-maybe)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile.
  2015-12-03 10:32 [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile Alex Kost
@ 2015-12-04 14:50 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-12-04 14:50 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Since a user may have several profiles, (s)he may want to load
> "…-autoloads.el" files from other profiles.  So this patch provides this
> possibility, i.e. if a user keeps his/her emacs packages in a separate
> profile, (s)he can do something like this:
>
> (setq guix-package-enable-at-startup nil)
> (require 'guix-init nil t)
> (guix-emacs-load-autoloads "/path/to/my/profile-with-emacs-packages")

Sounds useful!

> From 1147b16c79cb176db8f26aa88b9e930a9dea2268 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 27 Nov 2015 16:07:20 +0300
> Subject: [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile.
>
> * emacs/guix-emacs.el (guix-emacs-load-autoloads): Use 'profile'
>   as an optional argument.
>   (guix-emacs-load-autoloads-maybe): Adjust accordingly.
> * emacs/guix-init.el: Likewise.

LGTM.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-04 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-03 10:32 [PATCH] emacs: 'guix-emacs-load-autoloads' takes a profile Alex Kost
2015-12-04 14:50 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).