emacs: Display guix command errors in the minibuffer.
* emacs/guix-main.scm (output+error): New procedure. (guix-command-output): Use it. * emacs/guix-base.el (guix-command-output): Display error output in the minibuffer.
This commit is contained in:
		
							parent
							
								
									46e17df661
								
							
						
					
					
						commit
						ea369ee1b0
					
				
					 2 changed files with 23 additions and 6 deletions
				
			
		|  | @ -1134,9 +1134,12 @@ The function is called with a single argument - a command line string." | ||||||
| 
 | 
 | ||||||
| (defun guix-command-output (args) | (defun guix-command-output (args) | ||||||
|   "Return string with 'guix ARGS ...' output." |   "Return string with 'guix ARGS ...' output." | ||||||
|   (guix-eval-read |   (cl-multiple-value-bind (output error) | ||||||
|    (apply #'guix-make-guile-expression |       (guix-eval (apply #'guix-make-guile-expression | ||||||
|           'guix-command-output args))) |                         'guix-command-output args)) | ||||||
|  |     ;; Remove trailing new space from the error string. | ||||||
|  |     (message (replace-regexp-in-string "\n\\'" "" (read error))) | ||||||
|  |     (read output))) | ||||||
| 
 | 
 | ||||||
| (defun guix-help-string (&optional commands) | (defun guix-help-string (&optional commands) | ||||||
|   "Return string with 'guix COMMANDS ... --help' output." |   "Return string with 'guix COMMANDS ... --help' output." | ||||||
|  |  | ||||||
|  | @ -71,6 +71,18 @@ | ||||||
| (define (list-maybe obj) | (define (list-maybe obj) | ||||||
|   (if (list? obj) obj (list obj))) |   (if (list? obj) obj (list obj))) | ||||||
| 
 | 
 | ||||||
|  | (define (output+error thunk) | ||||||
|  |   "Call THUNK and return 2 values: output and error output as strings." | ||||||
|  |   (let ((output-port (open-output-string)) | ||||||
|  |         (error-port  (open-output-string))) | ||||||
|  |     (with-output-to-port output-port | ||||||
|  |       (lambda () (with-error-to-port error-port thunk))) | ||||||
|  |     (let ((strings (list (get-output-string output-port) | ||||||
|  |                          (get-output-string error-port)))) | ||||||
|  |       (close-output-port output-port) | ||||||
|  |       (close-output-port error-port) | ||||||
|  |       (apply values strings)))) | ||||||
|  | 
 | ||||||
| (define (full-name->name+version spec) | (define (full-name->name+version spec) | ||||||
|   "Given package specification SPEC with or without output, |   "Given package specification SPEC with or without output, | ||||||
| return two values: name and version.  For example, for SPEC | return two values: name and version.  For example, for SPEC | ||||||
|  | @ -953,9 +965,11 @@ GENERATIONS is a list of generation numbers." | ||||||
|     (const #t))) |     (const #t))) | ||||||
| 
 | 
 | ||||||
| (define (guix-command-output . args) | (define (guix-command-output . args) | ||||||
|   "Return string with 'guix ARGS ...' output." |   "Return 2 strings with 'guix ARGS ...' output and error output." | ||||||
|   (with-output-to-string |   (output+error | ||||||
|     (lambda () (apply guix-command args)))) |    (lambda () | ||||||
|  |      (parameterize ((guix-warning-port (current-error-port))) | ||||||
|  |        (apply guix-command args))))) | ||||||
| 
 | 
 | ||||||
| (define (help-string . commands) | (define (help-string . commands) | ||||||
|   "Return string with 'guix COMMANDS ... --help' output." |   "Return string with 'guix COMMANDS ... --help' output." | ||||||
|  |  | ||||||
		Reference in a new issue