Subject: Re: bug#74027: [PATCH] ; Insert "Stealing lock" at the beginning of a message

From: Philip Kaludercic <[email-masked]>
Date: Fri, 08 Nov 2024 16:10:22 +0000

Eli Zaretskii <[email-masked]> writes:

>> From: Philip Kaludercic <[email-masked]>
>> Cc: [email-masked]
>> Date: Fri, 08 Nov 2024 15:26:40 +0000
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> From: Philip Kaludercic <[email-masked]>
>> >> Cc: [email-masked]
>> >> Date: Fri, 08 Nov 2024 14:15:53 +0000
>> >> 
>> >> Eli Zaretskii <[email-masked]> writes:
>> >> 
>> >> >> -    (goto-char (point-max))
>> >> >> +    (mail-text)
>> >> >
>> >> > I guess you are using sendmail.el as your mail-user-agent?  But the
>> >> > default is message.el, so I think we should either use
>> >> > message-goto-body here, 
>> >> 
>> >> Ok, I falsely assumed that using 'mail-text' would be more compatible.
>> >> 
>> >> >                         
>> >> >                         or perhaps dispatch to either to message.el or
>> >> > sendmail.el based on the value of mail-user-agent.
>> >> 
>> >> So a `cond' expression checking mail-user-agent and then invoking the
>> >> right function, or is there some more generic way to do that?
>> >
>> > The former, I think.
>> 
>> In that case it seems better/simpler to just use 'message-goto-body'.
>
> I'm not sure.  I use sendmail, and I don't really like the idea of
> having message.el loaded into my sessions.
>
> It shouldn't be hard to dispatch, is it?

Technically no, just if we want to be exhaustive then I don't have a
good overview of all clients.  Or should we just fall-back onto message:

>From 728f6e64b4c11099a0b70c748dbae2183e28f918 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <[email-masked]>
Date: Sat, 26 Oct 2024 09:39:00 +0200
Subject: [PATCH] ; Insert "Stealing lock" at the beginning of a message

* lisp/vc/vc.el (vc-steal-lock): Use 'mail-text' instead of
jumping to 'point-max', to avoid inserting the message after
signatures.
---
 lisp/vc/vc.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 194b181f3e9..dd6079d22ab 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1738,6 +1738,8 @@ vc-mark-resolved
 	 (format "%d files" (length files))
        "this file"))))
 
+(declare-function mail-text "sendmail" ())
+(declare-function message-goto-body "message" (&optional interactive))
 (defun vc-steal-lock (file rev owner)
   "Steal the lock on FILE."
   (let (file-description)
@@ -1758,7 +1760,10 @@ vc-steal-lock
     ;; goes wrong, we don't want to send any mail.
     (compose-mail owner (format "Stolen lock on %s" file-description))
     (setq default-directory (expand-file-name "~/"))
-    (goto-char (point-max))
+    (cond
+     ((eq mail-user-agent 'sendmail-user-agent)
+      (mail-text))
+     ((message-goto-body)))
     (insert
      (format "I stole the lock on %s, " file-description)
      (current-time-string)
-- 
2.45.2

-- 
	Philip Kaludercic on siskin