discussion and development of Emacs Snakemake mode
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Switch to Transient
@ 2022-02-22  3:02 Kyle Meyer
  2022-02-22  3:02 ` [PATCH 1/3] Rewrite snakemake-popup as a transient Kyle Meyer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kyle Meyer @ 2022-02-22  3:02 UTC (permalink / raw)
  To: snakemake-mode

The first patch makes the long overdue switch from Magit Popup to
Transient.  While working on that, I realized that the --jobs argument
is now out of date.  The second and third patches deal with that.

  [1/3] Rewrite snakemake-popup as a transient
  [2/3] transient: Replace --jobs with --cores
  [3/3] transient: Use --cores=all by default

 .github/workflows/test.yml |  6 +--
 Makefile                   |  2 +-
 NEWS                       |  8 ++++
 README                     |  7 +--
 snakemake-mode.el          |  2 +-
 snakemake.el               | 91 ++++++++++++++++++++++----------------
 6 files changed, 69 insertions(+), 47 deletions(-)


base-commit: 8684b45cf53e403c7b0ebf31d899aa239a821f45
--
2.34.0

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

* [PATCH 1/3] Rewrite snakemake-popup as a transient
  2022-02-22  3:02 [PATCH 0/3] Switch to Transient Kyle Meyer
@ 2022-02-22  3:02 ` Kyle Meyer
  2022-02-22  3:02 ` [PATCH 2/3] transient: Replace --jobs with --cores Kyle Meyer
  2022-02-22  3:02 ` [PATCH 3/3] transient: Use --cores=all by default Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2022-02-22  3:02 UTC (permalink / raw)
  To: snakemake-mode

Magit switched to Transient for its popups a while go.  Magit Popup is
still around for third-party libraries that may use it, but it's not
actively developed.

At the moment, this switch is trading one external library for another
(improved) one.  However, Transient will ship with Emacs starting with
the upcoming 28.1 release.
---
 .github/workflows/test.yml |  6 +--
 Makefile                   |  2 +-
 NEWS                       |  4 ++
 README                     |  7 +--
 snakemake-mode.el          |  2 +-
 snakemake.el               | 90 +++++++++++++++++++++-----------------
 6 files changed, 64 insertions(+), 47 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 6772f36..a6d0ef2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -19,11 +19,11 @@ jobs:
       with:
         repository: magnars/dash.el
         path: dash.el
-    - name: Check out magit-popup
+    - name: Check out transient
       uses: actions/checkout@v2
       with:
-        repository: magit/magit-popup
-        path: magit-popup
+        repository: magit/transient
+        path: transient
     - name: Check out snakemake-mode
       uses: actions/checkout@v2
       with:
diff --git a/Makefile b/Makefile
index d93192a..8dd1437 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 
-LOAD_PATH = -L ../magit-popup -L ../dash.el -L .
+LOAD_PATH = -L ../transient/lisp -L ../dash.el -L .
 EMACS = emacs
 BATCH = $(EMACS) -Q --batch $(LOAD_PATH)
 CURL := curl --silent
diff --git a/NEWS b/NEWS
index 2674114..73e2e20 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ NEWS -- history of user-visible changes             -*- mode: org; -*-
 
 * master (unreleased)
 
+- The Magit Popup command ~snakemake-popup~ has been rewritten as a
+  transient, ~snakemake~.  snakemake.el now depends on Transient
+  rather than Magit Popup.
+
 - The 'name' keyword (new in Snakemake v5.31.0) is now recognized.
 
 * v1.8.0
diff --git a/README b/README
index 56b368d..556bdc2 100644
--- a/README
+++ b/README
@@ -7,7 +7,7 @@ This repo contains two Emacs libraries for Snakemake [^1].
   * snakemake-mode.el provides a major mode for editing Snakemake
     files.
 
-  * snakemake.el defines a popup interface for calling Snakemake.
+  * snakemake.el defines a transient [^2] for calling Snakemake.
 
 See the header of each file for more information.
 
@@ -16,6 +16,7 @@ Both of these are available on MELPA under the snakemake-mode package:
   https://melpa.org/#/snakemake-mode
 
 [^1]: https://snakemake.readthedocs.io/en/stable/
+[^2]: https://magit.vc/manual/transient/
 
 
 Contributing
@@ -27,8 +28,8 @@ Please send a plain-text email to
     snakemake-mode@inbox.kyleam.com
 
 Messages that include this address are public and available as
-public-inbox [^2] archives at
+public-inbox [^3] archives at
 
     https://inbox.kyleam.com/snakemake-mode/
 
-[^2]: https://public-inbox.org/README
+[^3]: https://public-inbox.org/README
diff --git a/snakemake-mode.el b/snakemake-mode.el
index 5e4118b..dcf2bf0 100644
--- a/snakemake-mode.el
+++ b/snakemake-mode.el
@@ -6,7 +6,7 @@
 ;; URL: https://git.kyleam.com/snakemake-mode/about
 ;; Keywords: tools
 ;; Version: 1.8.0
-;; Package-Requires: ((emacs "24.5") (cl-lib "0.5") (magit-popup "2.4.0"))
+;; Package-Requires: ((emacs "24.5") (cl-lib "0.5") (transient "0.3.0"))
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
diff --git a/snakemake.el b/snakemake.el
index e533def..61f6cbb 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -20,14 +20,13 @@
 
 ;;; Commentary:
 
-;; This package provides a popup interface, built on Magit's popup
-;; library [1], for calling Snakemake [2].  The main entry point is
-;; `snakemake-popup', which you should consider giving a global key
-;; binding.
+;; This package provides a Transient interface [1] for calling
+;; Snakemake [2].  The main entry point is the `snakemake' command,
+;; which you should consider giving a global key binding.
 ;;
-;; The popup currently includes four actions, all which lead to a
-;; Snakemake call.  What's different between the actions is how
-;; targets are selected.
+;; The `snakemake' transient currently includes four actions, all
+;; which lead to a Snakemake call.  What's different between the
+;; actions is how targets are selected.
 ;;
 ;; snakemake-build-targets-at-point
 ;;
@@ -78,13 +77,13 @@
 ;; terminal can be created with `snakemake-term-start', in which case
 ;; commands are sent there instead.
 ;;
-;; In addition to the popup commands, there are commands for showing
-;; and saving the dependency graph of a target.  The command
-;; `snakemake-graph' displays the graph in a buffer.  From this
-;; buffer, `snakemake-graph-save' can be called to save the graph to
-;; an output file.
+;; In addition to the commands in the transient, there are commands
+;; for showing and saving the dependency graph of a target.  The
+;; command `snakemake-graph' displays the graph in a buffer.  From
+;; this buffer, `snakemake-graph-save' can be called to save the graph
+;; to an output file.
 ;;
-;; [1] https://magit.vc/manual/magit-popup.html
+;; [1] https://magit.vc/manual/transient/
 ;; [2] https://snakemake.github.io/
 
 ;;; Code:
@@ -92,7 +91,7 @@
 (require 'cl-lib)
 (require 'compile)
 (require 'term)
-(require 'magit-popup)
+(require 'transient)
 
 (require 'snakemake-mode)
 
@@ -672,7 +671,7 @@ (defun snakemake-build-targets-at-point (&optional args)
   "Build target(s) at point without any prompts.
 
 $ snakemake [ARGS] -- <targets>"
-  (interactive (list (snakemake-arguments)))
+  (interactive (list (transient-args 'snakemake)))
   (snakemake-build-targets
    (or (snakemake-file-targets-at-point 'check)
        (snakemake-rule-at-point 'target)
@@ -684,7 +683,7 @@ (defun snakemake-build-file-target (&optional args)
   "Build target file.
 
 $ snakemake [ARGS] -- <file>"
-  (interactive (list (snakemake-arguments)))
+  (interactive (list (transient-args 'snakemake)))
   (snakemake-build-targets
    (list (snakemake-read-file-target))
    args))
@@ -694,7 +693,7 @@ (defun snakemake-build-rule-target (&optional args)
   "Build target rule, prompting with known rules.
 
 $ snakemake [ARGS] -- <rule>"
-  (interactive (list (snakemake-arguments)))
+  (interactive (list (transient-args 'snakemake)))
   (snakemake-build-targets
    (list (snakemake-read-rule 'targets))
    args))
@@ -711,7 +710,7 @@ (defun snakemake-build (&optional args)
 `\\[snakemake-term-start]'.
 
 $ snakemake [ARGS] -- <targets>"
-  (interactive (list (snakemake-arguments)))
+  (interactive (list (transient-args 'snakemake)))
   (let ((cmd (snakemake--make-command
               (or (snakemake-file-targets-at-point)
                   (snakemake-rule-at-point)
@@ -727,27 +726,40 @@ (defun snakemake-build (&optional args)
 
 (define-obsolete-function-alias 'snakemake-compile 'snakemake-build "1.2.0")
 
-;;;###autoload (autoload 'snakemake-popup "snakemake" nil t)
-(magit-define-popup snakemake-popup
-  "Popup console for running Snakemake."
-  :switches
-  '((?c "Use conda" "--use-conda")
-    (?f "Force" "--force")
-    (?i "Ignore temp()" "--notemp")
-    (?n "Dry run" "--dryrun")
-    (?p "Print shell commands" "-p")
-    (?r "Print reason" "--reason")
-    (?t "Touch files" "--touch"))
-  :options
-  '((?a "Allowed rules" "--allowed-rules " snakemake-read-rules)
-    (?j "Number of jobs" "-j"))
-  :actions
-  '((?c "Edit and run command" snakemake-build) nil nil
-    (?p "Build target at point" snakemake-build-targets-at-point)
-    (?f "Build file" snakemake-build-file-target)
-    (?r "Build rule" snakemake-build-rule-target))
-  :default-action 'snakemake-compile
-  :max-action-columns 3)
+(transient-define-argument snakemake:--allowed-rules ()
+  :description "Allowed rules"
+  :class 'transient-option
+  :key "-a"
+  :argument "--allowed-rules="
+  :reader 'snakemake-read-rules)
+
+(transient-define-argument snakemake:--jobs ()
+  :description "Number of jobs"
+  :class 'transient-option
+  :key "-j"
+  :argument "--jobs=")
+
+;;;###autoload (autoload 'snakemake "snakemake" nil t)
+(transient-define-prefix snakemake
+  "Transient for running Snakemake."
+  ["Arguments"
+   ("-c" "Use conda" "--use-conda")
+   ("-f" "Force" "--force")
+   ("-i" "Ignore temp()" "--notemp")
+   ("-n" "Dry run" "--dryrun")
+   ("-p" "Print shell commands" "-p")
+   ("-r" "Print reason" "--reason")
+   ("-t" "Touch files" "--touch")
+   (snakemake:--allowed-rules)
+   (snakemake:--jobs)]
+  ["Actions"
+   [("c" "Edit and run command" snakemake-build)]
+   [("p" "Build target at point" snakemake-build-targets-at-point)
+    ("f" "Build file" snakemake-build-file-target)
+    ("r" "Build rule" snakemake-build-rule-target)]])
+
+;;;###autoload
+(define-obsolete-function-alias 'snakemake-popup 'snakemake "2.0.0")
 
 (provide 'snakemake)
 ;;; snakemake.el ends here
-- 
2.34.0


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

* [PATCH 2/3] transient: Replace --jobs with --cores
  2022-02-22  3:02 [PATCH 0/3] Switch to Transient Kyle Meyer
  2022-02-22  3:02 ` [PATCH 1/3] Rewrite snakemake-popup as a transient Kyle Meyer
@ 2022-02-22  3:02 ` Kyle Meyer
  2022-02-22  3:02 ` [PATCH 3/3] transient: Use --cores=all by default Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2022-02-22  3:02 UTC (permalink / raw)
  To: snakemake-mode

--cores was added as a synonym for --jobs in v3.10.0 (2012), and, as
of v6.5.0, --cores and --jobs are distinct things for cloud/cluster
jobs.  Wait to add --jobs until it's requested.
---
 NEWS         |  4 ++++
 snakemake.el | 12 ++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 73e2e20..64db66f 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ NEWS -- history of user-visible changes             -*- mode: org; -*-
   transient, ~snakemake~.  snakemake.el now depends on Transient
   rather than Magit Popup.
 
+- The ~--jobs~ argument in the ~snakemake~ transient has been replaced
+  by ~--cores~ to follow upstream changes.  ~--cores~ is bound to
+  ~-c~, and ~--use-conda~ has been moved from ~-c~ to ~-C~.
+
 - The 'name' keyword (new in Snakemake v5.31.0) is now recognized.
 
 * v1.8.0
diff --git a/snakemake.el b/snakemake.el
index 61f6cbb..91fef4f 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -733,17 +733,17 @@ (transient-define-argument snakemake:--allowed-rules ()
   :argument "--allowed-rules="
   :reader 'snakemake-read-rules)
 
-(transient-define-argument snakemake:--jobs ()
-  :description "Number of jobs"
+(transient-define-argument snakemake:--cores ()
+  :description "Number of cores"
   :class 'transient-option
-  :key "-j"
-  :argument "--jobs=")
+  :key "-c"
+  :argument "--cores=")
 
 ;;;###autoload (autoload 'snakemake "snakemake" nil t)
 (transient-define-prefix snakemake
   "Transient for running Snakemake."
   ["Arguments"
-   ("-c" "Use conda" "--use-conda")
+   ("-C" "Use conda" "--use-conda")
    ("-f" "Force" "--force")
    ("-i" "Ignore temp()" "--notemp")
    ("-n" "Dry run" "--dryrun")
@@ -751,7 +751,7 @@ (transient-define-prefix snakemake
    ("-r" "Print reason" "--reason")
    ("-t" "Touch files" "--touch")
    (snakemake:--allowed-rules)
-   (snakemake:--jobs)]
+   (snakemake:--cores)]
   ["Actions"
    [("c" "Edit and run command" snakemake-build)]
    [("p" "Build target at point" snakemake-build-targets-at-point)
-- 
2.34.0


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

* [PATCH 3/3] transient: Use --cores=all by default
  2022-02-22  3:02 [PATCH 0/3] Switch to Transient Kyle Meyer
  2022-02-22  3:02 ` [PATCH 1/3] Rewrite snakemake-popup as a transient Kyle Meyer
  2022-02-22  3:02 ` [PATCH 2/3] transient: Replace --jobs with --cores Kyle Meyer
@ 2022-02-22  3:02 ` Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2022-02-22  3:02 UTC (permalink / raw)
  To: snakemake-mode

--cores has been a mandatory argument since v5.11.  Set the default to
something that can actually build targets.
---
 snakemake.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/snakemake.el b/snakemake.el
index 91fef4f..98467ce 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -742,6 +742,7 @@ (transient-define-argument snakemake:--cores ()
 ;;;###autoload (autoload 'snakemake "snakemake" nil t)
 (transient-define-prefix snakemake
   "Transient for running Snakemake."
+  :value '("--cores=all")
   ["Arguments"
    ("-C" "Use conda" "--use-conda")
    ("-f" "Force" "--force")
-- 
2.34.0


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

end of thread, other threads:[~2022-02-22  3:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22  3:02 [PATCH 0/3] Switch to Transient Kyle Meyer
2022-02-22  3:02 ` [PATCH 1/3] Rewrite snakemake-popup as a transient Kyle Meyer
2022-02-22  3:02 ` [PATCH 2/3] transient: Replace --jobs with --cores Kyle Meyer
2022-02-22  3:02 ` [PATCH 3/3] transient: Use --cores=all by default Kyle Meyer

Code repositories for project(s) associated with this inbox:

	https://git.kyleam.com/snakemake-mode/

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).