From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 3/3] emacs: Add "View build log" action to build popup. Date: Sun, 13 Sep 2015 22:39:21 +0300 Message-ID: <1442173161-527-4-git-send-email-alezost@gmail.com> References: <1442173161-527-1-git-send-email-alezost@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbD8U-0003oa-Uv for guix-devel@gnu.org; Sun, 13 Sep 2015 15:40:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbD8Q-0000fs-L5 for guix-devel@gnu.org; Sun, 13 Sep 2015 15:40:26 -0400 In-Reply-To: <1442173161-527-1-git-send-email-alezost@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org * emacs/guix-command.el (guix-run-view-build-log): New function. (guix-command-additional-execute-arguments, guix-command-special-executors): Add entries for "View build log" action. * emacs/guix-utils.el (guix-find-file-or-url): New function. --- emacs/guix-command.el | 19 ++++++++++++++++++- emacs/guix-utils.el | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/emacs/guix-command.el b/emacs/guix-command.el index 81f619f..ddafac9 100644 --- a/emacs/guix-command.el +++ b/emacs/guix-command.el @@ -497,7 +497,10 @@ to be modified." "List of default 'execute' action arguments.") (defvar guix-command-additional-execute-arguments - `((("graph") + `((("build") + ,(guix-command-make-argument + :name "log" :char ?l :doc "View build log")) + (("graph") ,(guix-command-make-argument :name "view" :char ?v :doc "View graph"))) "Alist of guix commands and additional 'execute' action arguments.") @@ -518,6 +521,8 @@ to be modified." ("repl" . guix-run-environment-command-in-repl)) (("pull") ("repl" . guix-run-pull-command-in-repl)) + (("build") + ("log" . guix-run-view-build-log)) (("graph") ("view" . guix-run-view-graph))) "Alist of guix commands and alists of special executers for them. @@ -556,6 +561,18 @@ Perform pull-specific actions after operation, see (apply #'guix-make-guile-expression 'guix-command args) nil 'pull)) +(defun guix-run-view-build-log (args) + "Add --log-file to ARGS, run 'guix ARGS ...' build command, and +open the log file(s)." + (let* ((args (if (member "--log-file" args) + args + (apply #'list (car args) "--log-file" (cdr args)))) + (output (guix-command-output args)) + (files (split-string output "\n" t))) + (dolist (file files) + (guix-find-file-or-url file) + (guix-build-log-mode)))) + (defun guix-run-view-graph (args) "Run 'guix ARGS ...' graph command, make the image and open it." (let* ((graph-file (guix-dot-file-name)) diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el index c1ce954..682609d 100644 --- a/emacs/guix-utils.el +++ b/emacs/guix-utils.el @@ -208,6 +208,16 @@ single argument." (funcall guix-find-file-function file) (message "File '%s' does not exist." file))) +(defvar url-handler-regexp) + +(defun guix-find-file-or-url (file-or-url) + "Find FILE-OR-URL." + (require 'url-handlers) + (let ((file-name-handler-alist + (cons (cons url-handler-regexp 'url-file-handler) + file-name-handler-alist))) + (find-file file-or-url))) + (defmacro guix-while-search (regexp &rest body) "Evaluate BODY after each search for REGEXP in the current buffer." (declare (indent 1) (debug t)) -- 2.5.1