unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add "View map" action to 'size' popup.
@ 2015-09-22 10:09 Alex Kost
  2015-09-22 21:33 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2015-09-22 10:09 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 37 bytes --]

Just another action for "M-x guix".


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Add-View-map-action-to-size-popup.patch --]
[-- Type: text/x-patch, Size: 2314 bytes --]

From aec97eb453a031352c48c678f49d9047628e82f7 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Mon, 21 Sep 2015 20:11:18 +0300
Subject: [PATCH] emacs: Add "View map" action to 'size' popup.

* emacs/guix-command.el (guix-run-view-size-map): New function.
  (guix-command-additional-execute-arguments,
  guix-command-special-executors): Add entries for "View map" action.
---
 emacs/guix-command.el | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/emacs/guix-command.el b/emacs/guix-command.el
index 6fdfb93..c573c8c 100644
--- a/emacs/guix-command.el
+++ b/emacs/guix-command.el
@@ -502,7 +502,10 @@ to be modified."
        :name "log" :char ?l :doc "View build log"))
     (("graph")
      ,(guix-command-make-argument
-       :name "view" :char ?v :doc "View graph")))
+       :name "view" :char ?v :doc "View graph"))
+    (("size")
+     ,(guix-command-make-argument
+       :name "view" :char ?v :doc "View map")))
   "Alist of guix commands and additional 'execute' action arguments.")
 
 (defun guix-command-execute-arguments (commands)
@@ -524,7 +527,9 @@ to be modified."
     (("build")
      ("log" . guix-run-view-build-log))
     (("graph")
-     ("view" . guix-run-view-graph)))
+     ("view" . guix-run-view-graph))
+    (("size")
+     ("view" . guix-run-view-size-map)))
   "Alist of guix commands and alists of special executers for them.
 See also `guix-command-default-executors'.")
 
@@ -582,6 +587,23 @@ open the log file(s)."
         (guix-find-file graph-file)
       (error "Couldn't create a graph"))))
 
+(defun guix-run-view-size-map (args)
+  "Run 'guix ARGS ...' size command, and open the map file."
+  (let* ((wished-map-file
+          (cl-some (lambda (arg)
+                     (and (string-match "--map-file=\\(.+\\)" arg)
+                          (match-string 1 arg)))
+                   args))
+         (map-file (or wished-map-file (guix-png-file-name)))
+         (args (if wished-map-file
+                   args
+                 (apply #'list
+                        (car args)
+                        (concat "--map-file=" map-file)
+                        (cdr args)))))
+    (guix-command-output args)
+    (guix-find-file map-file)))
+
 \f
 ;;; Generating popups, actions, etc.
 
-- 
2.5.0


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

* Re: [PATCH] emacs: Add "View map" action to 'size' popup.
  2015-09-22 10:09 [PATCH] emacs: Add "View map" action to 'size' popup Alex Kost
@ 2015-09-22 21:33 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-09-22 21:33 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From aec97eb453a031352c48c678f49d9047628e82f7 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Mon, 21 Sep 2015 20:11:18 +0300
> Subject: [PATCH] emacs: Add "View map" action to 'size' popup.
>
> * emacs/guix-command.el (guix-run-view-size-map): New function.
>   (guix-command-additional-execute-arguments,
>   guix-command-special-executors): Add entries for "View map" action.

Nice, go ahead.

Thanks,
Ludo’.

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

end of thread, other threads:[~2015-09-22 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 10:09 [PATCH] emacs: Add "View map" action to 'size' popup Alex Kost
2015-09-22 21:33 ` 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).