unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add "View graph" actions to system graph commands.
@ 2015-10-15 19:46 Alex Kost
  2015-10-16  8:16 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Kost @ 2015-10-15 19:46 UTC (permalink / raw)
  To: guix-devel

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

I like graph commands.  Thanks, Ludo!

This patch adds "View graph" action for the new "M-x guix RET system"
commands.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Add-View-graph-actions-to-system-graph-command.patch --]
[-- Type: text/x-patch, Size: 3714 bytes --]

From 79027171c9be2cececde951caf54758c4e1bb8f5 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 15 Oct 2015 22:10:32 +0300
Subject: [PATCH] emacs: Add "View graph" actions to system graph commands.

* emacs/guix-command.el (guix-command-additional-execute-arguments,
  guix-command-special-executors): Add "View graph" actions for
  'dmd-graph' and 'extension-graph' commands.
* doc/emacs.texi (Emacs Popup Interface): Document "View graph" action.
---
 doc/emacs.texi        | 31 +++++++++++++++++++++++++++++++
 emacs/guix-command.el | 26 ++++++++++++++++----------
 2 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index ab69515..cfd2301 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -531,6 +531,37 @@ GNU Emacs Manual}).
 
 @end itemize
 
+Several commands (@command{guix graph}, @command{guix system dmd-graph}
+and @command{guix system extension-graph}) also have a ``View graph''
+action, which allows to view a generated graph using @command{dot}
+command (specified by @code{guix-dot-program} variable).  By default a
+PNG file will be saved in @file{/tmp} directory and will be opened
+directly in Emacs.  This behavior may be changed with the following
+variables:
+
+@table @code
+
+@item guix-find-file-function
+Function used to open a generated graph.  If you want to open a graph in
+an external program, you can do it by modifying this variable---for
+example, you can use a functionality provided by the Org Mode
+(@pxref{Top,,, org, The Org Manual}):
+
+@example
+(setq guix-find-file-function 'org-open-file)
+(add-to-list 'org-file-apps '("\\.png\\'" . "sxiv %s"))
+@end example
+
+@item guix-dot-default-arguments
+Command line arguments to run @command{dot} command.  If you change an
+output format (for example, into @code{-Tpdf}), you also need to change
+the next variable.
+
+@item guix-dot-file-name-function
+Function used to define a name of the generated graph file.  Default
+name is @file{/tmp/graph-XXXXXX.png}.
+
+@end table
 
 @node Emacs Prettify
 @section Guix Prettify Mode
diff --git a/emacs/guix-command.el b/emacs/guix-command.el
index 3ae7791..1a42594 100644
--- a/emacs/guix-command.el
+++ b/emacs/guix-command.el
@@ -499,15 +499,17 @@ to be modified."
   "List of default 'execute' action arguments.")
 
 (defvar guix-command-additional-execute-arguments
-  `((("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"))
-    (("size")
-     ,(guix-command-make-argument
-       :name "view" :char ?v :doc "View map")))
+  (let ((graph-arg (guix-command-make-argument
+                    :name "view" :char ?v :doc "View graph")))
+    `((("build")
+       ,(guix-command-make-argument
+         :name "log" :char ?l :doc "View build log"))
+      (("graph") ,graph-arg)
+      (("size")
+       ,(guix-command-make-argument
+         :name "view" :char ?v :doc "View map"))
+      (("system" "dmd-graph") ,graph-arg)
+      (("system" "extension-graph") ,graph-arg)))
   "Alist of guix commands and additional 'execute' action arguments.")
 
 (defun guix-command-execute-arguments (commands)
@@ -531,7 +533,11 @@ to be modified."
     (("graph")
      ("view" . guix-run-view-graph))
     (("size")
-     ("view" . guix-run-view-size-map)))
+     ("view" . guix-run-view-size-map))
+    (("system" "dmd-graph")
+     ("view" . guix-run-view-graph))
+    (("system" "extension-graph")
+     ("view" . guix-run-view-graph)))
   "Alist of guix commands and alists of special executers for them.
 See also `guix-command-default-executors'.")
 
-- 
2.5.0


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

* Re: [PATCH] emacs: Add "View graph" actions to system graph commands.
  2015-10-15 19:46 [PATCH] emacs: Add "View graph" actions to system graph commands Alex Kost
@ 2015-10-16  8:16 ` Ludovic Courtès
  2015-10-16 16:57   ` [PATCH] doc: emacs: Document "View graph" popup action Alex Kost
  2015-10-16 16:58   ` [PATCH] emacs: Improve file names of generated graphs Alex Kost
  0 siblings, 2 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-10-16  8:16 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From 79027171c9be2cececde951caf54758c4e1bb8f5 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 15 Oct 2015 22:10:32 +0300
> Subject: [PATCH] emacs: Add "View graph" actions to system graph commands.
>
> * emacs/guix-command.el (guix-command-additional-execute-arguments,
>   guix-command-special-executors): Add "View graph" actions for
>   'dmd-graph' and 'extension-graph' commands.
> * doc/emacs.texi (Emacs Popup Interface): Document "View graph" action.

Excellent!

Perhaps the documentation part should go in a separate commit since it’s
not strictly related to the new commands?

> +Several commands (@command{guix graph}, @command{guix system dmd-graph}
> +and @command{guix system extension-graph}) also have a ``View graph''
> +action, which allows to view a generated graph using @command{dot}
                      ^^^
“which allows you to view”

> +command (specified by @code{guix-dot-program} variable).  By default a
> +PNG file will be saved in @file{/tmp} directory and will be opened

Not directly related to this patch, but I wonder if this would work with
a PDF opened with DocView?  That would allow people to zoom in etc.

> +@item guix-dot-file-name-function
> +Function used to define a name of the generated graph file.  Default
> +name is @file{/tmp/graph-XXXXXX.png}.

Not related to this patch either, but we might consider changing the
template to /tmp/guix-el-graph-XXXX.png for clarity.

Otherwise LGTM.

Thank you!

Ludo’.

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

* [PATCH] doc: emacs: Document "View graph" popup action.
  2015-10-16  8:16 ` Ludovic Courtès
@ 2015-10-16 16:57   ` Alex Kost
  2015-10-17 13:23     ` Ludovic Courtès
  2015-10-16 16:58   ` [PATCH] emacs: Improve file names of generated graphs Alex Kost
  1 sibling, 1 reply; 6+ messages in thread
From: Alex Kost @ 2015-10-16 16:57 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

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

Ludovic Courtès (2015-10-16 11:16 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> From 79027171c9be2cececde951caf54758c4e1bb8f5 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Thu, 15 Oct 2015 22:10:32 +0300
>> Subject: [PATCH] emacs: Add "View graph" actions to system graph commands.
>>
>> * emacs/guix-command.el (guix-command-additional-execute-arguments,
>>   guix-command-special-executors): Add "View graph" actions for
>>   'dmd-graph' and 'extension-graph' commands.
>> * doc/emacs.texi (Emacs Popup Interface): Document "View graph" action.
>
> Excellent!
>
> Perhaps the documentation part should go in a separate commit since it’s
> not strictly related to the new commands?

Yes, I agree.  I have split it and pushed the part to add "View graph"
actions.

>> +Several commands (@command{guix graph}, @command{guix system dmd-graph}
>> +and @command{guix system extension-graph}) also have a ``View graph''
>> +action, which allows to view a generated graph using @command{dot}
>                       ^^^
> “which allows you to view”

Fixed.

>> +command (specified by @code{guix-dot-program} variable).  By default a
>> +PNG file will be saved in @file{/tmp} directory and will be opened
>
> Not directly related to this patch, but I wonder if this would work with
> a PDF opened with DocView?  That would allow people to zoom in etc.

Sure, you can generate any type of graph and open it inside or outside
emacs, whatever you want.  I have added an example for this case (in the
attached patch), so please report if it's not clear.  Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-doc-emacs-Document-View-graph-popup-action.patch --]
[-- Type: text/x-patch, Size: 2175 bytes --]

From 70e53141ee1767e09fdc2b0a48e3cf82323b3482 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 16 Oct 2015 17:50:36 +0300
Subject: [PATCH] doc: emacs: Document "View graph" popup action.

* doc/emacs.texi (Emacs Popup Interface): Document "View graph" action.
---
 doc/emacs.texi | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index ab69515..0e901e1 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -531,6 +531,49 @@ GNU Emacs Manual}).
 
 @end itemize
 
+Several commands (@command{guix graph}, @command{guix system dmd-graph}
+and @command{guix system extension-graph}) also have a ``View graph''
+action, which allows you to view a generated graph using @command{dot}
+command (specified by @code{guix-dot-program} variable).  By default a
+PNG file will be saved in @file{/tmp} directory and will be opened
+directly in Emacs.  This behavior may be changed with the following
+variables:
+
+@table @code
+
+@item guix-find-file-function
+Function used to open a generated graph.  If you want to open a graph in
+an external program, you can do it by modifying this variable---for
+example, you can use a functionality provided by the Org Mode
+(@pxref{Top,,, org, The Org Manual}):
+
+@example
+(setq guix-find-file-function 'org-open-file)
+(add-to-list 'org-file-apps '("\\.png\\'" . "sxiv %s"))
+@end example
+
+@item guix-dot-default-arguments
+Command line arguments to run @command{dot} command.  If you change an
+output format (for example, into @code{-Tpdf}), you also need to change
+the next variable.
+
+@item guix-dot-file-name-function
+Function used to define a name of the generated graph file.  Default
+name is @file{/tmp/guix-emacs-graph-XXXXXX.png}.
+
+@end table
+
+So, for example, if you want to generate and open a PDF file in your
+Emacs, you may change the settings like this:
+
+@example
+(defun my-guix-pdf-graph ()
+  "/tmp/my-current-guix-graph.pdf")
+
+(setq guix-dot-default-arguments '("-Tpdf")
+      guix-dot-file-name-function 'my-guix-pdf-graph)
+@end example
+
 
 @node Emacs Prettify
 @section Guix Prettify Mode
-- 
2.5.0


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

* [PATCH] emacs: Improve file names of generated graphs.
  2015-10-16  8:16 ` Ludovic Courtès
  2015-10-16 16:57   ` [PATCH] doc: emacs: Document "View graph" popup action Alex Kost
@ 2015-10-16 16:58   ` Alex Kost
  2015-10-17 13:23     ` Ludovic Courtès
  1 sibling, 1 reply; 6+ messages in thread
From: Alex Kost @ 2015-10-16 16:58 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

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

Ludovic Courtès (2015-10-16 11:16 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
[...]
>> +@item guix-dot-file-name-function
>> +Function used to define a name of the generated graph file.  Default
>> +name is @file{/tmp/graph-XXXXXX.png}.
>
> Not related to this patch either, but we might consider changing the
> template to /tmp/guix-el-graph-XXXX.png for clarity.

Indeed!  I don't like "el" part though, what about "guix-emacs-graph-"
instead? (as in the attached patch)


[-- Attachment #2: 0001-emacs-Improve-file-names-of-generated-graphs.patch --]
[-- Type: text/x-patch, Size: 1103 bytes --]

From 6dd1084f14723484028df86c04e7c997538fc951 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 16 Oct 2015 17:27:58 +0300
Subject: [PATCH] emacs: Improve file names of generated graphs.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by Ludovic Courtès <ludo@gnu.org>.

* emacs/guix-external.el (guix-png-file-name): Change prefix of a file
  name to "guix-emacs-graph-" to avoid possible conflicts.
---
 emacs/guix-external.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/guix-external.el b/emacs/guix-external.el
index d233473..580676e 100644
--- a/emacs/guix-external.el
+++ b/emacs/guix-external.el
@@ -64,7 +64,7 @@ If ARGS is nil, use `guix-dot-default-arguments'."
   "Return '.png' file name in the `temporary-file-directory'."
   (concat (make-temp-name
            (concat (file-name-as-directory temporary-file-directory)
-                   "graph-"))
+                   "guix-emacs-graph-"))
           ".png"))
 
 (provide 'guix-external)
-- 
2.5.0


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

* Re: [PATCH] doc: emacs: Document "View graph" popup action.
  2015-10-16 16:57   ` [PATCH] doc: emacs: Document "View graph" popup action Alex Kost
@ 2015-10-17 13:23     ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-10-17 13:23 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-10-16 11:16 +0300) wrote:

[...]

>> Not directly related to this patch, but I wonder if this would work with
>> a PDF opened with DocView?  That would allow people to zoom in etc.
>
> Sure, you can generate any type of graph and open it inside or outside
> emacs, whatever you want.  I have added an example for this case (in the
> attached patch), so please report if it's not clear.  Thanks!
>
>
> From 70e53141ee1767e09fdc2b0a48e3cf82323b3482 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 16 Oct 2015 17:50:36 +0300
> Subject: [PATCH] doc: emacs: Document "View graph" popup action.
>
> * doc/emacs.texi (Emacs Popup Interface): Document "View graph" action.

[...]

> +So, for example, if you want to generate and open a PDF file in your
> +Emacs, you may change the settings like this:
> +
> +@example
> +(defun my-guix-pdf-graph ()
> +  "/tmp/my-current-guix-graph.pdf")
> +
> +(setq guix-dot-default-arguments '("-Tpdf")
> +      guix-dot-file-name-function 'my-guix-pdf-graph)

Ah yes, perfect.

Thanks!

Ludo’.

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

* Re: [PATCH] emacs: Improve file names of generated graphs.
  2015-10-16 16:58   ` [PATCH] emacs: Improve file names of generated graphs Alex Kost
@ 2015-10-17 13:23     ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-10-17 13:23 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From 6dd1084f14723484028df86c04e7c997538fc951 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 16 Oct 2015 17:27:58 +0300
> Subject: [PATCH] emacs: Improve file names of generated graphs.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Suggested by Ludovic Courtès <ludo@gnu.org>.
>
> * emacs/guix-external.el (guix-png-file-name): Change prefix of a file
>   name to "guix-emacs-graph-" to avoid possible conflicts.

LGTM, thanks!

Ludo’.

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

end of thread, other threads:[~2015-10-17 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15 19:46 [PATCH] emacs: Add "View graph" actions to system graph commands Alex Kost
2015-10-16  8:16 ` Ludovic Courtès
2015-10-16 16:57   ` [PATCH] doc: emacs: Document "View graph" popup action Alex Kost
2015-10-17 13:23     ` Ludovic Courtès
2015-10-16 16:58   ` [PATCH] emacs: Improve file names of generated graphs Alex Kost
2015-10-17 13:23     ` 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).