summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-base.el27
-rw-r--r--emacs/guix-buffer.el4
-rw-r--r--emacs/guix-build-log.el3
-rw-r--r--emacs/guix-devel.el3
-rw-r--r--emacs/guix-init.el3
-rw-r--r--emacs/guix-main.scm4
-rw-r--r--emacs/guix-profiles.el8
-rw-r--r--emacs/guix-ui-package.el59
8 files changed, 84 insertions, 27 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 9f9f258451..1248ecbce5 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -55,6 +55,14 @@
 If it is not set by a user, it is set after starting Guile REPL.
 This directory is used to define location of the packages.")
 
+(defun guix-read-directory ()
+  "Return `guix-directory' or prompt for it.
+This function is intended for using in `interactive' forms."
+  (if current-prefix-arg
+      (read-directory-name "Directory with Guix modules: "
+                           guix-directory)
+    guix-directory))
+
 (defun guix-set-directory ()
   "Set `guix-directory' if needed."
   (or guix-directory
@@ -63,17 +71,17 @@ This directory is used to define location of the packages.")
 
 (add-hook 'guix-after-start-repl-hook 'guix-set-directory)
 
-(defun guix-find-location (location)
+(defun guix-find-location (location &optional directory)
   "Go to LOCATION of a package.
 LOCATION is a string of the form:
 
   \"PATH:LINE:COLUMN\"
 
 If PATH is relative, it is considered to be relative to
-`guix-directory'."
+DIRECTORY (`guix-directory' by default)."
   (cl-multiple-value-bind (path line col)
       (split-string location ":")
-    (let ((file (expand-file-name path guix-directory))
+    (let ((file (expand-file-name path (or directory guix-directory)))
           (line (string-to-number line))
           (col  (string-to-number col)))
       (find-file file)
@@ -113,12 +121,17 @@ See `guix-packages-profile'."
                     (guix-packages-profile profile generation system?)))
 
 ;;;###autoload
-(defun guix-edit (id-or-name)
-  "Edit (go to location of) package with ID-OR-NAME."
-  (interactive (list (guix-read-package-name)))
+(defun guix-edit (id-or-name &optional directory)
+  "Edit (go to location of) package with ID-OR-NAME.
+See `guix-find-location' for the meaning of package location and
+DIRECTORY.
+Interactively, with prefix argument, prompt for DIRECTORY."
+  (interactive
+   (list (guix-read-package-name)
+         (guix-read-directory)))
   (let ((loc (guix-package-location id-or-name)))
     (if loc
-        (guix-find-location loc)
+        (guix-find-location loc directory)
       (message "Couldn't find package location."))))
 
 
diff --git a/emacs/guix-buffer.el b/emacs/guix-buffer.el
index af76e638b6..4cefe9989e 100644
--- a/emacs/guix-buffer.el
+++ b/emacs/guix-buffer.el
@@ -241,8 +241,10 @@ HISTORY should be one of the following:
   `replace' - replace the current history item."
   (guix-buffer-with-item buffer-item
     (when %entries
-      (guix-buffer-show-entries %entries %buffer-type %entry-type)
+      ;; Set buffer item before showing entries, so that its value can
+      ;; be used by the code for displaying entries.
       (setq guix-buffer-item buffer-item)
+      (guix-buffer-show-entries %entries %buffer-type %entry-type)
       (when history
         (funcall (cl-ecase history
                    (add     #'guix-history-add)
diff --git a/emacs/guix-build-log.el b/emacs/guix-build-log.el
index e08a88f6cc..f67be16326 100644
--- a/emacs/guix-build-log.el
+++ b/emacs/guix-build-log.el
@@ -367,6 +367,9 @@ programmatically using hooks:
   (guix-build-log-mode))
 
 ;;;###autoload
+(add-hook 'shell-mode-hook 'guix-build-log-minor-mode-activate-maybe)
+
+;;;###autoload
 (add-to-list 'auto-mode-alist
              ;; Regexp for log files (usually placed in /var/log/guix/...)
              (cons (rx "/guix/drvs/" (= 2 alnum) "/" (= 30 alnum)
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index 8eb030942c..ee8371ce81 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -364,6 +364,9 @@ bindings:
   (when guix-devel-activate-mode
     (guix-devel-mode)))
 
+;;;###autoload
+(add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe)
+
 
 (defvar guix-devel-emacs-font-lock-keywords
   (eval-when-compile
diff --git a/emacs/guix-init.el b/emacs/guix-init.el
index 47ced6abaa..1d7d258f69 100644
--- a/emacs/guix-init.el
+++ b/emacs/guix-init.el
@@ -1,7 +1,4 @@
 (require 'guix-autoloads)
 (require 'guix-emacs)
 
-(add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe)
-(add-hook 'shell-mode-hook 'guix-build-log-minor-mode-activate-maybe)
-
 (provide 'guix-init)
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 335686ed25..11b9c773b9 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -856,9 +856,7 @@ parameter/value pairs."
 
 (define* (package->manifest-entry* package #:optional output)
   (and package
-       (begin
-         (check-package-freshness package)
-         (package->manifest-entry package output))))
+       (package->manifest-entry package output)))
 
 (define* (make-install-manifest-entries id #:optional output)
   (package->manifest-entry* (package-by-id id) output))
diff --git a/emacs/guix-profiles.el b/emacs/guix-profiles.el
index 43ad1d42eb..12cf46dbf8 100644
--- a/emacs/guix-profiles.el
+++ b/emacs/guix-profiles.el
@@ -40,6 +40,14 @@
 (defvar guix-current-profile guix-default-profile
   "Current profile.")
 
+(defvar guix-system-profile-regexp
+  (concat "\\`" (regexp-quote guix-system-profile))
+  "Regexp matching system profiles.")
+
+(defun guix-system-profile? (profile)
+  "Return non-nil, if PROFILE is a system one."
+  (string-match-p guix-system-profile-regexp profile))
+
 (defun guix-profile-prompt (&optional default)
   "Prompt for profile and return it.
 Use DEFAULT as a start directory.  If it is nil, use
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index 0971fdd438..d6d26335fa 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -454,17 +454,22 @@ current OUTPUT is installed (if there is such output in
                              (string= (guix-entry-value entry 'output)
                                       output))
                            installed))
-         (action-type (if installed-entry 'delete 'install)))
+         (action-type (if installed-entry 'delete 'install))
+         (profile (guix-ui-current-profile)))
     (guix-info-insert-indent)
     (guix-format-insert output
                         (if installed-entry
                             'guix-package-info-installed-outputs
                           'guix-package-info-uninstalled-outputs)
                         guix-package-info-output-format)
-    (guix-package-info-insert-action-button action-type entry output)
-    (when obsolete
-      (guix-info-insert-indent)
-      (guix-package-info-insert-action-button 'upgrade entry output))
+    ;; Do not allow a user to install/delete anything to/from a system
+    ;; profile, so add action buttons only for non-system profiles.
+    (when (and profile
+               (not (guix-system-profile? profile)))
+      (guix-package-info-insert-action-button action-type entry output)
+      (when obsolete
+        (guix-info-insert-indent)
+        (guix-package-info-insert-action-button 'upgrade entry output)))
     (insert "\n")
     (when installed-entry
       (guix-info-insert-entry installed-entry 'installed-output 2))))
@@ -723,10 +728,22 @@ take an entry as argument."
             'upgrade nil
             (guix-package-installed-outputs entry)))))
 
+(defun guix-package-assert-non-system-profile ()
+  "Verify that the current profile is not a system one.
+The current profile is the one used by the current buffer."
+  (let ((profile (guix-ui-current-profile)))
+    (and profile
+         (guix-system-profile? profile)
+         (user-error "Packages cannot be installed or removed to/from \
+profile '%s'.
+Use 'guix system reconfigure' shell command to modify a system profile."
+                     profile))))
+
 (defun guix-package-execute-actions (fun)
   "Perform actions on the marked packages.
 Use FUN to define actions suitable for `guix-process-package-actions'.
 FUN should take action-type as argument."
+  (guix-package-assert-non-system-profile)
   (let ((actions (delq nil
                        (mapcar fun '(install delete upgrade)))))
     (if actions
@@ -746,10 +763,11 @@ The specification is suitable for `guix-process-package-actions'."
   (let ((specs (guix-list-get-marked-args action-type)))
     (and specs (cons action-type specs))))
 
-(defun guix-package-list-edit ()
-  "Go to the location of the current package."
-  (interactive)
-  (guix-edit (guix-list-current-id)))
+(defun guix-package-list-edit (&optional directory)
+  "Go to the location of the current package.
+See `guix-find-location' for the meaning of DIRECTORY."
+  (interactive (list (guix-read-directory)))
+  (guix-edit (guix-list-current-id) directory))
 
 (defun guix-package-list-latest-builds (number &rest args)
   "Display latest NUMBER of Hydra builds of the current package.
@@ -906,11 +924,13 @@ See `guix-package-info-type'."
                  'id (cl-remove-duplicates pids))
        'add))))
 
-(defun guix-output-list-edit ()
-  "Go to the location of the current package."
-  (interactive)
+(defun guix-output-list-edit (&optional directory)
+  "Go to the location of the current package.
+See `guix-find-location' for the meaning of DIRECTORY."
+  (interactive (list (guix-read-directory)))
   (guix-edit (guix-entry-value (guix-list-current-entry)
-                               'package-id)))
+                               'package-id)
+             directory))
 
 
 ;;; Interactive commands
@@ -979,6 +999,19 @@ Interactively with prefix, prompt for PROFILE."
   (guix-package-get-display profile 'installed))
 
 ;;;###autoload
+(defun guix-installed-user-packages ()
+  "Display information about Guix packages installed in a user profile."
+  (interactive)
+  (guix-installed-packages guix-user-profile))
+
+;;;###autoload
+(defun guix-installed-system-packages ()
+  "Display information about Guix packages installed in a system profile."
+  (interactive)
+  (guix-installed-packages
+   (guix-packages-profile guix-system-profile nil t)))
+
+;;;###autoload
 (defun guix-obsolete-packages (&optional profile)
   "Display information about obsolete Guix packages.
 If PROFILE is nil, use `guix-current-profile'.