1 ;;; guix-emacs.el --- Emacs packages installed with Guix
3 ;; Copyright © 2014 Alex Kost <alezost@gmail.com>
5 ;; This file is part of GNU Guix.
7 ;; GNU Guix is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Guix is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;; This file provides auxiliary code for working with Emacs packages
23 ;; installed with Guix.
27 (require 'guix-profiles
)
29 (defcustom guix-emacs-activate-after-operation t
30 "Activate Emacs packages after installing.
31 If nil, do not load autoloads of the Emacs packages after
32 they are successfully installed."
36 (defvar guix-emacs-autoloads nil
37 "List of the last loaded Emacs autoloads.")
39 (defun guix-emacs-directory (&optional profile
)
40 "Return directory with Emacs packages installed in PROFILE.
41 If PROFILE is nil, use `guix-user-profile'."
42 (expand-file-name "share/emacs/site-lisp"
43 (or profile guix-user-profile
)))
45 (defun guix-emacs-find-autoloads (&optional profile
)
46 "Return list of autoloads of Emacs packages installed in PROFILE.
47 If PROFILE is nil, use `guix-user-profile'.
48 Return nil if there are no emacs packages installed in PROFILE."
49 (let ((dir (guix-emacs-directory profile
)))
50 (if (file-directory-p dir
)
51 (directory-files dir
'full-name
"-autoloads\\.el\\'")
52 (message "Directory '%s' does not exist." dir
)
56 (defun guix-emacs-load-autoloads (&optional all
)
57 "Load autoloads for Emacs packages installed in a user profile.
58 If ALL is nil, activate only those packages that were installed
59 after the last activation, otherwise activate all Emacs packages
60 installed in `guix-user-profile'."
62 (let* ((autoloads (guix-emacs-find-autoloads))
65 (cl-nset-difference autoloads guix-emacs-autoloads
69 (setq guix-emacs-autoloads autoloads
)))
71 (defun guix-emacs-load-autoloads-maybe ()
72 "Load autoloads for Emacs packages if needed.
73 See `guix-emacs-activate-after-operation' for details."
74 (and guix-emacs-activate-after-operation
75 (guix-emacs-load-autoloads)))
79 ;;; guix-emacs.el ends here