Factored out log-action.
authorSaba Saba <saba@sabadev.xyz>
Thu, 9 Feb 2023 17:26:24 +0000 (12:26 -0500)
committerSaba Saba <saba@sabadev.xyz>
Thu, 9 Feb 2023 17:26:24 +0000 (12:26 -0500)
git-repl.cl

index 626990d..a4b1a63 100644 (file)
      (export ',name)
      (defun ,name ,arglist ,@body)))
 
+(defmacro log-action (description &body body)
+  `(progn
+     (write-line ,description)
+     ,@body))
+
 (defmacro clean-working-directory (&body body)
   `(if (null (modified-files))
        (progn ,@body)
 (defun-public stash-config ()
   "Stashes your current configuration by first unskipping it and then stashing it. This operation fails if you have any modified files."
   (clean-working-directory
-    (write-line "Unskipping files...")
-    (no-skip-all)
-    (write-line "Stashing files...")
-    (save-stash)))
+    (log-action "Unskipping files..." (no-skip-all))
+    (log-action "Stashing files..." (save-stash))))
 
 (defun-public pop-config ()
   "Pops the stash and skips it to store it as your configuration. This operation fails if you have any modified files."
   (clean-working-directory
-    (write-line "Popping stash...")
-    (pop-stash)
-    (write-line "Skipping files...")
-    (skip-modified)))
+    (log-action "Popping stash..." (pop-stash))
+    (log-action "Skipping files..." (skip-modified))))
 
 (defun-public apply-config ()
   "Applies the stash and skips it to store it as your configuration. This operation fails if you have any modified files."
   (clean-working-directory
-    (write-line "Applying stash...")
-    (apply-stash)
-    (write-line "Skipping files...")
-    (skip-modified)))
+    (log-action "Applying stash..." (apply-stash))
+    (log-action "Skipping files..." (skip-modified))))
 
 (defun-public config-diff (file-path)
   "Saves the current configuration to the specified file"