unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/4] emacs: Show built output directories in Package Info.
@ 2016-05-28 14:36 Alex Kost
  2016-05-28 14:36 ` [PATCH 2/4] emacs: Extend 'guix-mapinsert' Alex Kost
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Alex Kost @ 2016-05-28 14:36 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm (package-store-path): New procedure.
* emacs/guix-base.el (guix-package-store-path): New procedure.
* emacs/guix-ui-package.el (guix-package-info-auto-find-package): New
variable.
(guix-package-info-show-store-path, guix-package-info-insert-misc): New
procedures.
(guix-package-info-format, guix-output-info-format): Add
'guix-package-info-insert-misc'.
---
 emacs/guix-base.el       |  7 ++++++
 emacs/guix-main.scm      | 11 ++++++++++
 emacs/guix-ui-package.el | 56 ++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 8888364..9620100 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -207,6 +207,13 @@ Ask a user with PROMPT for continuing an operation."
    (guix-make-guile-expression
     'package-source-path package-id)))
 
+(defun guix-package-store-path (package-id)
+  "Return a list of store directories of outputs of package PACKAGE-ID."
+  (message "Calculating the package derivation ...")
+  (guix-eval-read
+   (guix-make-guile-expression
+    'package-store-path package-id)))
+
 (defvar guix-after-source-download-hook nil
   "Hook run after successful performing a 'source-download' operation.")
 
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index e645a85..c4f1b4a 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -953,6 +953,17 @@ GENERATIONS is a list of generation numbers."
                ((package _ ...) package)))
          (compose location->string package-location)))
 
+(define (package-store-path package-id)
+  "Return a list of store directories of outputs of package PACKAGE-ID."
+  (match (package-by-id package-id)
+    (#f '())
+    (package
+      (with-store store
+        (map (match-lambda
+               ((_ . drv)
+                (derivation-output-path drv)))
+             (derivation-outputs (package-derivation store package)))))))
+
 (define (package-source-derivation->store-path derivation)
   "Return a store path of the package source DERIVATION."
   (match (derivation-outputs derivation)
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index edc3648..eebecc7 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -222,6 +222,7 @@ ENTRIES is a list of package entries to get info about packages."
             (description ignore (simple guix-package-info-description))
             ignore
             (outputs simple guix-package-info-insert-outputs)
+            guix-package-info-insert-misc
             (source simple guix-package-info-insert-source)
             (location simple guix-package-info-insert-location)
             (home-url format (format guix-url))
@@ -309,9 +310,15 @@ ENTRIES is a list of package entries to get info about packages."
   "Face used if a package is obsolete."
   :group 'guix-package-info-faces)
 
+(defcustom guix-package-info-auto-find-package t
+  "If non-nil, open store directory after pressing \"Show\" package button.
+If nil, just display the store directory (or directories) without finding."
+  :type 'boolean
+  :group 'guix-package-info)
+
 (defcustom guix-package-info-auto-find-source nil
-  "If non-nil, find a source file after pressing a \"Show\" button.
-If nil, just display the source file path without finding."
+  "If non-nil, open source file after pressing \"Show\" source button.
+If nil, just display the source file name without finding."
   :type 'boolean
   :group 'guix-package-info)
 
@@ -521,6 +528,50 @@ ENTRY is an alist with package info."
              (guix-entry-id entry))
      'output output)))
 
+(defun guix-package-info-show-store-path (entry-id package-id)
+  "Show store directories of the package outputs in the current buffer.
+ENTRY-ID is an ID of the current entry (package or output).
+PACKAGE-ID is an ID of the package which store path to show."
+  (let* ((entries (guix-buffer-current-entries))
+         (entry   (guix-entry-by-id entry-id entries))
+         (dirs    (guix-package-store-path package-id)))
+    (or dirs
+        (error "Couldn't define store directory of the package"))
+    (let* ((new-entry (cons (cons 'store-path dirs)
+                            entry))
+           (new-entries (guix-replace-entry entry-id new-entry entries)))
+      (setf (guix-buffer-item-entries guix-buffer-item)
+            new-entries)
+      (guix-buffer-redisplay-goto-button)
+      (let ((dir (car dirs)))
+        (if (file-exists-p dir)
+            (if guix-package-info-auto-find-package
+                (find-file dir)
+              (message nil))
+          (message "'%s' does not exist.\nTry to build this package."
+                   dir))))))
+
+(defun guix-package-info-insert-misc (entry)
+  "Insert various buttons and other info for package ENTRY at point."
+  (if (guix-entry-value entry 'obsolete)
+      (guix-format-insert nil)
+    (let* ((entry-id   (guix-entry-id entry))
+           (package-id (or (guix-entry-value entry 'package-id)
+                           entry-id))
+           (store-path (guix-entry-value entry 'store-path)))
+      (guix-info-insert-title-simple "Package")
+      (if store-path
+          (guix-info-insert-value-indent store-path 'guix-file)
+        (guix-info-insert-action-button
+         "Show"
+         (lambda (btn)
+           (guix-package-info-show-store-path
+            (button-get btn 'entry-id)
+            (button-get btn 'package-id)))
+         "Show the store directory of the current package"
+         'entry-id entry-id
+         'package-id package-id)))))
+
 (defun guix-package-info-show-source (entry-id package-id)
   "Show file name of a package source in the current info buffer.
 Find the file if needed (see `guix-package-info-auto-find-source').
@@ -817,6 +868,7 @@ for all ARGS."
             (version format guix-output-info-insert-version)
             (output format guix-output-info-insert-output)
             (synopsis simple (indent guix-package-info-synopsis))
+            guix-package-info-insert-misc
             (source simple guix-package-info-insert-source)
             (path simple (indent guix-file))
             (dependencies simple (indent guix-file))
-- 
2.7.3

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

end of thread, other threads:[~2016-06-01 21:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-28 14:36 [PATCH 1/4] emacs: Show built output directories in Package Info Alex Kost
2016-05-28 14:36 ` [PATCH 2/4] emacs: Extend 'guix-mapinsert' Alex Kost
2016-05-30 21:14   ` Ludovic Courtès
2016-05-28 14:36 ` [PATCH 3/4] emacs: Add "Build" button to Package Info Alex Kost
2016-05-30 21:15   ` Ludovic Courtès
2016-05-28 14:36 ` [PATCH 4/4] emacs: Add "Build Log" " Alex Kost
2016-05-30 21:17   ` Ludovic Courtès
2016-05-31 21:09     ` Alex Kost
2016-06-01 21:04       ` Ludovic Courtès
2016-05-30 21:13 ` [PATCH 1/4] emacs: Show built output directories in " 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).