From 2c04e2eec8bf250d1e928b7c8b1e60424b0b32fa Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 7 Feb 2016 11:08:57 +0300 Subject: emacs: 'C-u M-x guix-edit' prompts for directory. * emacs/guix-base.el (guix-read-directory): New procedure. (guix-find-location, guix-edit): Add optional 'directory' argument. * emacs/guix-ui-package.el (guix-package-list-edit) (guix-output-list-edit): Likewise. * doc/emacs.texi (Emacs Commands): Mention "C-u". --- emacs/guix-ui-package.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'emacs/guix-ui-package.el') diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el index 0971fdd438..ff10a1e75c 100644 --- a/emacs/guix-ui-package.el +++ b/emacs/guix-ui-package.el @@ -746,10 +746,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 +907,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 -- cgit v1.2.3 From cfb1c62aa98965daacb216713be650057188e65e Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 11 Feb 2016 11:21:56 +0300 Subject: emacs: Add 'M-x guix-installed-{user/system}-packages'. * emacs/guix-ui-package.el (guix-installed-user-packages) (guix-installed-system-packages): New commands. * doc/emacs.texi (Emacs Commands): Document them. --- doc/emacs.texi | 8 +++++++- emacs/guix-ui-package.el | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'emacs/guix-ui-package.el') diff --git a/doc/emacs.texi b/doc/emacs.texi index dbe59f0243..27f5365caa 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -150,7 +150,13 @@ Commands for displaying packages: Display all/newest available packages. @item M-x guix-installed-packages -Display all installed packages. +@itemx M-x guix-installed-user-packages +@itemx M-x guix-installed-system-packages +Display installed packages. As described above, @kbd{M-x +guix-installed-packages} uses an arbitrary profile that you can specify, +while the other commands display packages installed in 2 special +profiles: @file{~/.guix-profile} and @file{/run/current-system/profile} +(only on GuixSD). @item M-x guix-obsolete-packages Display obsolete packages (the packages that are installed in a profile diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el index ff10a1e75c..78d2c40848 100644 --- a/emacs/guix-ui-package.el +++ b/emacs/guix-ui-package.el @@ -981,6 +981,19 @@ Interactively with prefix, prompt for PROFILE." (interactive (list (guix-ui-read-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. -- cgit v1.2.3 From 260795b7369c51d99c7ab4f3ef24f195938beabf Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Fri, 12 Feb 2016 12:32:34 +0300 Subject: emacs: Do not allow a user to modify system profiles. Fixes . Reported by myglc2 . Remove possibilities to install/delete packages to/from a system profile both for "Package List" and "Package Info" buffers. * emacs/guix-profiles.el (guix-system-profile-regexp): New variable. (guix-system-profile?): New procedure. * emacs/guix-ui-package.el (guix-package-info-insert-output): Do not display "Install"/"Delete" button for a system profile. (guix-package-assert-non-system-profile): New procedure. (guix-package-execute-actions): Use it. --- emacs/guix-profiles.el | 8 ++++++++ emacs/guix-ui-package.el | 27 ++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'emacs/guix-ui-package.el') 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 78d2c40848..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 -- cgit v1.2.3