Subject: bug#69017: 30.0.50; [debbugs] Make compilation step optional in debbugs-gnu-apply-patch

From: Eric Abrahamsen <[email-masked]>
Date: Sat, 10 Feb 2024 12:52:42 -0800

Eli Zaretskii <[email-masked]> writes:

>> From: Eric Abrahamsen <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Sat, 10 Feb 2024 11:58:56 -0800
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> Cc: [email-masked]
>> >> From: Eric Abrahamsen <[email-masked]>
>> >> Date: Sat, 10 Feb 2024 11:23:30 -0800
>> >> 
>> >> Out of curiosity, do you use any convenience functions for applying
>> >> patches from email->repository?
>> >
>> > I use M-|, FWIW.
>> 
>> That's what I was trying to avoid! You're the one who has to handle
>> attachments vs inline, type out the directory location, decide between
>> "git am" and "git apply", etc...
>> 
>> If you're doing it 50 times a day, maybe the muscle memory (or command
>> history) means it's not a big deal.
>
> Emacs remembers the command history, so all I have to do is press <UP>
> a few times, after I type M-|, then type RET.
>
> And some figuring out is still up to you, because patches could be for
> the release branch or for the master (and maybe for a few more
> branches), so you'd need some "cd foo" before "git am".  I have a
> command for master and for the release branch, and I need to decide
> which one to use in each case.  That cannot be automated.

Yup, that makes plenty of sense. Your situation is more complicated than
mine, no surprise there!

I've attached the minimum workable approach, which just lets the user
set the compile command to nil to skip compilation, and the relevant
window rearrangements afterwards.

A fuller solution might be a "after-apply-patch-actions" option, that takes a
list like '(compile vc). That could obviate
`debbugs-gnu-apply-patch-prefers-magit' because you could just set the
list to '(compile magit) instead. But that would require a pretty
thorough reworking of the window munging code that comes at the end, and
I'd like to just keep this simple.

>From 861d000d35f8ed90ed47ce7cff980157d1329408 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <[email-masked]>
Date: Sat, 10 Feb 2024 12:38:31 -0800
Subject: [PATCH] Don't compile after applying a patch, if compile command is
 nil

* debbugs-gnu.el (debbugs-gnu-apply-patch): Allow the user to set
debbugs-gnu-compile-command to nil to skip the compile step.
---
 debbugs-gnu.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index a5453334cd..f4f1fce7da 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -2612,12 +2612,13 @@ If SELECTIVELY, query the user before applying the patch."
       (insert-file-contents-literally rej))
     (goto-char (point-max))
     (save-some-buffers t)
-    (require 'compile)
-    (mapc #'kill-process compilation-in-progress)
-    (compile
-     (format "cd %s; %s"
-	     debbugs-gnu-current-directory
-	     debbugs-gnu-compile-command))
+    (when debbugs-gnu-compile-command
+      (require 'compile)
+      (mapc #'kill-process compilation-in-progress)
+      (compile
+       (format "cd %s; %s"
+	       debbugs-gnu-current-directory
+	       debbugs-gnu-compile-command)))
     (let (buf)
       (if (debbugs-gnu-apply-patch-prefers-magit)
           (progn
@@ -2637,11 +2638,12 @@ If SELECTIVELY, query the user before applying the patch."
       (delete-other-windows)
       (switch-to-buffer output-buffer)
       (split-window)
-      (split-window)
-      (other-window 1)
-      (switch-to-buffer "*compilation*")
-      (goto-char (point-max))
-      (other-window 1)
+      (when debbugs-gnu-compile-command
+       (split-window)
+       (other-window 1)
+       (switch-to-buffer "*compilation*")
+       (goto-char (point-max))
+       (other-window 1))
       (switch-to-buffer buf)
       (goto-char (point-min)))))
 
-- 
2.43.0