* [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
* [PATCH 2/4] emacs: Extend 'guix-mapinsert'.
2016-05-28 14:36 [PATCH 1/4] emacs: Show built output directories in Package Info Alex Kost
@ 2016-05-28 14:36 ` 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
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Alex Kost @ 2016-05-28 14:36 UTC (permalink / raw)
To: guix-devel
* emacs/guix-utils.el (guix-mapinsert): Add 'indent' and 'column'
keyword arguments.
---
emacs/guix-utils.el | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index ea9933f..3e4ecc3 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -84,16 +84,33 @@ If FORMAT is non-nil, format VAL with FORMAT."
(format format str)
str))))
-(defun guix-mapinsert (function sequence separator)
+(cl-defun guix-mapinsert (function sequence separator &key indent column)
"Like `mapconcat' but for inserting text.
Apply FUNCTION to each element of SEQUENCE, and insert SEPARATOR
-at point between each FUNCTION call."
- (when sequence
- (funcall function (car sequence))
- (mapc (lambda (obj)
- (insert separator)
- (funcall function obj))
- (cdr sequence))))
+at point between each FUNCTION call.
+
+If INDENT is non-nil, it should be a number of spaces used to
+indent each line of the inserted text.
+
+If COLUMN is non-nil, it should be a column number which
+shouldn't be exceeded by the inserted text."
+ (pcase sequence
+ (`(,first . ,rest)
+ (let* ((indent (or indent 0))
+ (max-column (and column (- column indent))))
+ (guix-with-indent indent
+ (funcall function first)
+ (dolist (element rest)
+ (let ((before-sep-pos (and column (point))))
+ (insert separator)
+ (let ((after-sep-pos (and column (point))))
+ (funcall function element)
+ (when (and column
+ (> (current-column) max-column))
+ (save-excursion
+ (delete-region before-sep-pos after-sep-pos)
+ (goto-char before-sep-pos)
+ (insert "\n")))))))))))
(defun guix-insert-button (label &optional type &rest properties)
"Make button of TYPE with LABEL and insert it at point.
--
2.7.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] emacs: Add "Build" button to Package Info.
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-28 14:36 ` 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:13 ` [PATCH 1/4] emacs: Show built output directories in " Ludovic Courtès
3 siblings, 1 reply; 10+ messages in thread
From: Alex Kost @ 2016-05-28 14:36 UTC (permalink / raw)
To: guix-devel
* emacs/guix-main.scm: Use (guix scripts) module for 'build-package'
procedure.
* emacs/guix-base.el (guix-build-package): New procedure.
* emacs/guix-ui-package.el (guix-package-info-insert-build-button): New
procedure.
(guix-package-info-button-functions): New variable.
(guix-package-info-insert-misc): Insert buttons using it.
---
emacs/guix-base.el | 14 ++++++++++++++
emacs/guix-main.scm | 1 +
emacs/guix-ui-package.el | 28 +++++++++++++++++++++++++++-
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 9620100..658cfdb 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -231,6 +231,20 @@ Ask a user with PROMPT for continuing an operation."
:dry-run? (or guix-dry-run 'f))
nil 'source-download)))
+(defun guix-build-package (package-id &optional prompt)
+ "Build package with PACKAGE-ID.
+Ask a user with PROMPT for continuing the build operation."
+ (when (or (not guix-operation-confirm)
+ (guix-operation-prompt (or prompt "Build package?")))
+ (guix-eval-in-repl
+ (format (concat ",run-in-store "
+ "(build-package (package-by-id %d)"
+ " #:use-substitutes? %s"
+ " #:dry-run? %s)")
+ package-id
+ (guix-guile-boolean guix-use-substitutes)
+ (guix-guile-boolean guix-dry-run)))))
+
;;;###autoload
(defun guix-apply-manifest (profile file &optional operation-buffer)
"Apply manifest from FILE to PROFILE.
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index c4f1b4a..8914933 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -51,6 +51,7 @@
(guix licenses)
(guix utils)
(guix ui)
+ (guix scripts)
(guix scripts package)
(gnu packages)
(gnu system))
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index eebecc7..4eb7083 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -332,6 +332,13 @@ prompt depending on `guix-operation-confirm' variable)."
:type 'boolean
:group 'guix-package-info)
+(defcustom guix-package-info-button-functions
+ '(guix-package-info-insert-build-button)
+ "List of functions used to insert package buttons in Info buffer.
+Each function is called with 2 arguments: package ID and full name."
+ :type '(repeat function)
+ :group 'guix-package-info)
+
(defvar guix-package-info-download-buffer nil
"Buffer from which a current download operation was performed.")
@@ -558,6 +565,7 @@ PACKAGE-ID is an ID of the package which store path to show."
(let* ((entry-id (guix-entry-id entry))
(package-id (or (guix-entry-value entry 'package-id)
entry-id))
+ (full-name (guix-package-entry->name-specification entry))
(store-path (guix-entry-value entry 'store-path)))
(guix-info-insert-title-simple "Package")
(if store-path
@@ -570,7 +578,25 @@ PACKAGE-ID is an ID of the package which store path to show."
(button-get btn 'package-id)))
"Show the store directory of the current package"
'entry-id entry-id
- 'package-id package-id)))))
+ 'package-id package-id))
+ (when guix-package-info-button-functions
+ (insert "\n")
+ (guix-mapinsert (lambda (fun)
+ (funcall fun package-id full-name))
+ guix-package-info-button-functions
+ (guix-info-get-indent)
+ :indent guix-info-indent
+ :column (guix-info-fill-column))))))
+
+(defun guix-package-info-insert-build-button (id full-name)
+ "Insert button to build a package defined by ID."
+ (guix-info-insert-action-button
+ "Build"
+ (lambda (btn)
+ (guix-build-package (button-get btn 'id)
+ (format "Build '%s' package?" full-name)))
+ (format "Build the current package")
+ 'id id))
(defun guix-package-info-show-source (entry-id package-id)
"Show file name of a package source in the current info buffer.
--
2.7.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] emacs: Add "Build Log" button to Package Info.
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-28 14:36 ` [PATCH 3/4] emacs: Add "Build" button to Package Info Alex Kost
@ 2016-05-28 14:36 ` Alex Kost
2016-05-30 21:17 ` Ludovic Courtès
2016-05-30 21:13 ` [PATCH 1/4] emacs: Show built output directories in " Ludovic Courtès
3 siblings, 1 reply; 10+ messages in thread
From: Alex Kost @ 2016-05-28 14:36 UTC (permalink / raw)
To: guix-devel
* emacs/guix-main.scm (package-build-log-file): New procedure.
* emacs/guix-ui-package.el (guix-package-build-log-file)
(guix-package-find-build-log)
(guix-package-info-insert-build-log-button): New procedures.
(guix-package-info-button-functions): Add
'guix-package-info-insert-build-log-button'.
---
emacs/guix-main.scm | 10 ++++++++++
emacs/guix-ui-package.el | 25 ++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 8914933..cbf7cdc 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -1000,6 +1000,16 @@ GENERATIONS is a list of generation numbers."
(format #t "The source store path: ~a~%"
(package-source-derivation->store-path derivation))))))
+(define (package-build-log-file package-id)
+ "Return the build log file of a package PACKAGE-ID.
+Return #f if the build log is not found."
+ (and-let* ((package (package-by-id package-id)))
+ (with-store store
+ (let* ((derivation (package-derivation store package))
+ (file (derivation-file-name derivation)))
+ (or (log-file store file)
+ ((@@ (guix scripts build) log-url) store file))))))
+
\f
;;; Executing guix commands
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index 4eb7083..4280246 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -111,6 +111,19 @@ is found and `guix-package-list-single' is nil."
(list (if (= 0 package-id) package-id-str package-id)
output))))
+(defun guix-package-build-log-file (id)
+ "Return build log file name of a package defined by ID."
+ (guix-eval-read
+ (guix-make-guile-expression 'package-build-log-file id)))
+
+(defun guix-package-find-build-log (id)
+ "Show build log of a package defined by ID."
+ (require 'guix-build-log)
+ (let ((file (guix-package-build-log-file id)))
+ (if file
+ (guix-build-log-find-file file)
+ (message "Couldn't find the package build log."))))
+
\f
;;; Processing package actions
@@ -333,7 +346,8 @@ prompt depending on `guix-operation-confirm' variable)."
:group 'guix-package-info)
(defcustom guix-package-info-button-functions
- '(guix-package-info-insert-build-button)
+ '(guix-package-info-insert-build-button
+ guix-package-info-insert-build-log-button)
"List of functions used to insert package buttons in Info buffer.
Each function is called with 2 arguments: package ID and full name."
:type '(repeat function)
@@ -598,6 +612,15 @@ PACKAGE-ID is an ID of the package which store path to show."
(format "Build the current package")
'id id))
+(defun guix-package-info-insert-build-log-button (id _name)
+ "Insert button to show build log of a package defined by ID."
+ (guix-info-insert-action-button
+ "Build Log"
+ (lambda (btn)
+ (guix-package-find-build-log (button-get btn 'id)))
+ "View build log of the current package"
+ 'id 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').
--
2.7.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] emacs: Add "Build Log" button to Package Info.
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
0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-05-30 21:17 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * emacs/guix-main.scm (package-build-log-file): New procedure.
> * emacs/guix-ui-package.el (guix-package-build-log-file)
> (guix-package-find-build-log)
> (guix-package-info-insert-build-log-button): New procedures.
> (guix-package-info-button-functions): Add
> 'guix-package-info-insert-build-log-button'.
OK!
I think having this extra info and extra buttons is nice. I wonder
though if in the future we should have a way to hide non-essential info
and buttons, so that someone who just wants to search and install/remove
software isn’t overwhelmed.
What are your thoughts?
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] emacs: Add "Build Log" button to Package Info.
2016-05-30 21:17 ` Ludovic Courtès
@ 2016-05-31 21:09 ` Alex Kost
2016-06-01 21:04 ` Ludovic Courtès
0 siblings, 1 reply; 10+ messages in thread
From: Alex Kost @ 2016-05-31 21:09 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2016-05-31 00:17 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> * emacs/guix-main.scm (package-build-log-file): New procedure.
>> * emacs/guix-ui-package.el (guix-package-build-log-file)
>> (guix-package-find-build-log)
>> (guix-package-info-insert-build-log-button): New procedures.
>> (guix-package-info-button-functions): Add
>> 'guix-package-info-insert-build-log-button'.
>
> OK!
Thanks, I've pushed this patchset.
> I think having this extra info and extra buttons is nice. I wonder
> though if in the future we should have a way to hide non-essential info
> and buttons, so that someone who just wants to search and install/remove
> software isn’t overwhelmed.
>
> What are your thoughts?
I agree that there may be too much buttons for a new user, but I
wouldn't like to hide features by default. For users, there is
'guix-package-info-format' variable. It is a bit complicated but it
allows to control any aspect of *Guix Package Info* buffer. For
example, one could hide all non-essential info like this:
(setq guix-package-info-format
'(guix-package-info-insert-heading
(outputs ignore guix-package-info-insert-outputs)))
--
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] emacs: Add "Build Log" button to Package Info.
2016-05-31 21:09 ` Alex Kost
@ 2016-06-01 21:04 ` Ludovic Courtès
0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-06-01 21:04 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> Ludovic Courtès (2016-05-31 00:17 +0300) wrote:
[...]
>> I think having this extra info and extra buttons is nice. I wonder
>> though if in the future we should have a way to hide non-essential info
>> and buttons, so that someone who just wants to search and install/remove
>> software isn’t overwhelmed.
>>
>> What are your thoughts?
>
> I agree that there may be too much buttons for a new user, but I
> wouldn't like to hide features by default. For users, there is
> 'guix-package-info-format' variable. It is a bit complicated but it
> allows to control any aspect of *Guix Package Info* buffer. For
> example, one could hide all non-essential info like this:
>
> (setq guix-package-info-format
> '(guix-package-info-insert-heading
> (outputs ignore guix-package-info-insert-outputs)))
OK, makes sense. Let’s keep it this way for now.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] emacs: Show built output directories in Package Info.
2016-05-28 14:36 [PATCH 1/4] emacs: Show built output directories in Package Info Alex Kost
` (2 preceding siblings ...)
2016-05-28 14:36 ` [PATCH 4/4] emacs: Add "Build Log" " Alex Kost
@ 2016-05-30 21:13 ` Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-05-30 21:13 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * 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'.
LGTM.
Ludo’.
^ permalink raw reply [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).