diff options
| author | Alex Kost <alezost@gmail.com> | 2014-11-26 01:32:24 +0300 |
|---|---|---|
| committer | Alex Kost <alezost@gmail.com> | 2014-12-02 22:09:22 +0300 |
| commit | 3db349cb09844e2770be3d0dee4e990f1228c2b6 (patch) | |
| tree | e9bfd03cdb38b69ed4146eae5589a53cd2c7e509 | |
| parent | ece9b4173b3e1d266e6171d3af656fbc93b51a8b (diff) | |
emacs: Move profiles code to "guix-profiles.el.in".
* emacs/guix-base.el (guix-user-profile, guix-default-profile,
guix-current-profile, guix-profile-prompt, guix-set-current-profile): Move
to...
* emacs/guix-init.el.in (guix-default-profile): Move to...
* emacs/guix-profiles.el.in: ... here. New file.
* configure.ac (AC_CONFIG_FILES): Add "emacs/guix-profiles.el".
* emacs.am (nodist_lisp_DATA): Likewise.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | configure.ac | 1 | ||||
| -rw-r--r-- | emacs.am | 3 | ||||
| -rw-r--r-- | emacs/guix-base.el | 42 | ||||
| -rw-r--r-- | emacs/guix-init.el.in | 7 | ||||
| -rw-r--r-- | emacs/guix-profiles.el.in | 62 |
6 files changed, 67 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore index a424a397c4e..bcb82aa26da 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -110,3 +110,4 @@ GTAGS | |||
| 110 | /emacs/guix-autoloads.el | 110 | /emacs/guix-autoloads.el |
| 111 | /emacs/guix-helper.scm | 111 | /emacs/guix-helper.scm |
| 112 | /emacs/guix-init.el | 112 | /emacs/guix-init.el |
| 113 | /emacs/guix-profiles.el | ||
diff --git a/configure.ac b/configure.ac index 9380f757672..235990edc34 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -185,6 +185,7 @@ AM_CONDITIONAL([HAVE_EMACS], [test "x$EMACS" != "xno"]) | |||
| 185 | emacsuidir="${guilemoduledir}/guix/emacs" | 185 | emacsuidir="${guilemoduledir}/guix/emacs" |
| 186 | AC_SUBST([emacsuidir]) | 186 | AC_SUBST([emacsuidir]) |
| 187 | AC_CONFIG_FILES([emacs/guix-init.el | 187 | AC_CONFIG_FILES([emacs/guix-init.el |
| 188 | emacs/guix-profiles.el | ||
| 188 | emacs/guix-helper.scm]) | 189 | emacs/guix-helper.scm]) |
| 189 | 190 | ||
| 190 | AC_OUTPUT | 191 | AC_OUTPUT |
| @@ -36,7 +36,8 @@ dist_lisp_DATA = \ | |||
| 36 | $(AUTOLOADS) | 36 | $(AUTOLOADS) |
| 37 | 37 | ||
| 38 | nodist_lisp_DATA = \ | 38 | nodist_lisp_DATA = \ |
| 39 | emacs/guix-init.el | 39 | emacs/guix-init.el \ |
| 40 | emacs/guix-profiles.el | ||
| 40 | 41 | ||
| 41 | $(AUTOLOADS): $(ELFILES) | 42 | $(AUTOLOADS): $(ELFILES) |
| 42 | $(EMACS) --batch --eval \ | 43 | $(EMACS) --batch --eval \ |
diff --git a/emacs/guix-base.el b/emacs/guix-base.el index 23575ac2bf1..5129c87a5df 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el | |||
| @@ -28,53 +28,13 @@ | |||
| 28 | ;;; Code: | 28 | ;;; Code: |
| 29 | 29 | ||
| 30 | (require 'cl-lib) | 30 | (require 'cl-lib) |
| 31 | (require 'guix-profiles) | ||
| 31 | (require 'guix-backend) | 32 | (require 'guix-backend) |
| 32 | (require 'guix-utils) | 33 | (require 'guix-utils) |
| 33 | (require 'guix-history) | 34 | (require 'guix-history) |
| 34 | (require 'guix-messages) | 35 | (require 'guix-messages) |
| 35 | 36 | ||
| 36 | 37 | ||
| 37 | ;;; Profiles | ||
| 38 | |||
| 39 | (defvar guix-user-profile | ||
| 40 | (expand-file-name "~/.guix-profile") | ||
| 41 | "User profile.") | ||
| 42 | |||
| 43 | (defvar guix-default-profile | ||
| 44 | (concat (or (getenv "NIX_STATE_DIR") "/var/guix") | ||
| 45 | "/profiles/per-user/" | ||
| 46 | (getenv "USER") | ||
| 47 | "/guix-profile") | ||
| 48 | "Default Guix profile.") | ||
| 49 | |||
| 50 | (defvar guix-current-profile guix-default-profile | ||
| 51 | "Current profile.") | ||
| 52 | |||
| 53 | (defun guix-profile-prompt (&optional default) | ||
| 54 | "Prompt for profile and return it. | ||
| 55 | Use DEFAULT as a start directory. If it is nil, use | ||
| 56 | `guix-current-profile'." | ||
| 57 | (let* ((path (read-file-name "Profile: " | ||
| 58 | (file-name-directory | ||
| 59 | (or default guix-current-profile)))) | ||
| 60 | (path (directory-file-name (expand-file-name path)))) | ||
| 61 | (if (string= path guix-user-profile) | ||
| 62 | guix-default-profile | ||
| 63 | path))) | ||
| 64 | |||
| 65 | (defun guix-set-current-profile (path) | ||
| 66 | "Set `guix-current-profile' to PATH. | ||
| 67 | Interactively, prompt for PATH. With prefix, use | ||
| 68 | `guix-default-profile'." | ||
| 69 | (interactive | ||
| 70 | (list (if current-prefix-arg | ||
| 71 | guix-default-profile | ||
| 72 | (guix-profile-prompt)))) | ||
| 73 | (setq guix-current-profile path) | ||
| 74 | (message "Current profile has been set to '%s'." | ||
| 75 | guix-current-profile)) | ||
| 76 | |||
| 77 | |||
| 78 | ;;; Parameters of the entries | 38 | ;;; Parameters of the entries |
| 79 | 39 | ||
| 80 | (defvar guix-param-titles | 40 | (defvar guix-param-titles |
diff --git a/emacs/guix-init.el.in b/emacs/guix-init.el.in index 4e627281875..775c90fef9d 100644 --- a/emacs/guix-init.el.in +++ b/emacs/guix-init.el.in | |||
| @@ -4,11 +4,4 @@ | |||
| 4 | (replace-regexp-in-string "${prefix}" "@prefix@" "@emacsuidir@") | 4 | (replace-regexp-in-string "${prefix}" "@prefix@" "@emacsuidir@") |
| 5 | "Directory with scheme files for \"guix.el\" package.") | 5 | "Directory with scheme files for \"guix.el\" package.") |
| 6 | 6 | ||
| 7 | (defvar guix-default-profile | ||
| 8 | (concat (or (getenv "NIX_STATE_DIR") "@guix_localstatedir@/guix") | ||
| 9 | "/profiles/per-user/" | ||
| 10 | (getenv "USER") | ||
| 11 | "/guix-profile") | ||
| 12 | "Default Guix profile.") | ||
| 13 | |||
| 14 | (provide 'guix-init) | 7 | (provide 'guix-init) |
diff --git a/emacs/guix-profiles.el.in b/emacs/guix-profiles.el.in new file mode 100644 index 00000000000..1e43707b682 --- /dev/null +++ b/emacs/guix-profiles.el.in | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | ;;; guix-profiles.el --- Guix profiles | ||
| 2 | |||
| 3 | ;; Copyright © 2014 Alex Kost <alezost@gmail.com> | ||
| 4 | |||
| 5 | ;; This file is part of GNU Guix. | ||
| 6 | |||
| 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. | ||
| 11 | |||
| 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. | ||
| 16 | |||
| 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/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (defvar guix-user-profile | ||
| 23 | (expand-file-name "~/.guix-profile") | ||
| 24 | "User profile.") | ||
| 25 | |||
| 26 | (defvar guix-default-profile | ||
| 27 | (concat (or (getenv "NIX_STATE_DIR") "@guix_localstatedir@/guix") | ||
| 28 | "/profiles/per-user/" | ||
| 29 | (getenv "USER") | ||
| 30 | "/guix-profile") | ||
| 31 | "Default Guix profile.") | ||
| 32 | |||
| 33 | (defvar guix-current-profile guix-default-profile | ||
| 34 | "Current profile.") | ||
| 35 | |||
| 36 | (defun guix-profile-prompt (&optional default) | ||
| 37 | "Prompt for profile and return it. | ||
| 38 | Use DEFAULT as a start directory. If it is nil, use | ||
| 39 | `guix-current-profile'." | ||
| 40 | (let* ((path (read-file-name "Profile: " | ||
| 41 | (file-name-directory | ||
| 42 | (or default guix-current-profile)))) | ||
| 43 | (path (directory-file-name (expand-file-name path)))) | ||
| 44 | (if (string= path guix-user-profile) | ||
| 45 | guix-default-profile | ||
| 46 | path))) | ||
| 47 | |||
| 48 | (defun guix-set-current-profile (path) | ||
| 49 | "Set `guix-current-profile' to PATH. | ||
| 50 | Interactively, prompt for PATH. With prefix, use | ||
| 51 | `guix-default-profile'." | ||
| 52 | (interactive | ||
| 53 | (list (if current-prefix-arg | ||
| 54 | guix-default-profile | ||
| 55 | (guix-profile-prompt)))) | ||
| 56 | (setq guix-current-profile path) | ||
| 57 | (message "Current profile has been set to '%s'." | ||
| 58 | guix-current-profile)) | ||
| 59 | |||
| 60 | (provide 'guix-profiles) | ||
| 61 | |||
| 62 | ;;; guix-profiles.el ends here | ||
