unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: rameiko87@posteo.net
Cc: 69738@debbugs.gnu.org
Subject: bug#69738: Followup
Date: Sat, 20 Apr 2024 14:11:51 +0300	[thread overview]
Message-ID: <86wmos8f0o.fsf@gnu.org> (raw)
In-Reply-To: <4d7b2d2317ad9512628fbd2725f33d8b@posteo.net> (rameiko87@posteo.net)

> Date: Mon, 15 Apr 2024 10:15:55 +0000
> From: rameiko87@posteo.net
> Cc: 69738@debbugs.gnu.org
> 
> > So please show a minimal
> > recipe for reproducing this, after applying the patch I sent, and
> > starting from "emacs -Q -nw".  There's probably something I'm missing.
> 
> emacs -nw -Q (FRAME 1 IS SCRATCH)
> C-x 5 2
> M-x load-file PATCH
> M-x rmail (FRAME 2 IS RMAIL)
> M-: (setq rmail-mail-new-frame t)
> C-x 5 2
> C-x b *Messages* (FRAME 3 IS MESSAGES)
> C-x 5 o (BACK TO FRAME 2)
> m (NEW MAIL OPENS ON FRAME 4)
> C-u - C-x 5 o (THIS IS WHAT THE PATCH DOES, REVERTING BACK TO FRAME 1 
> WHICH IS SCRATCH AND NOT RMAIL)
> 
> Does it make sense?

I guess it does, although it evidently breaks the expectations of
Rmail.  Please try a more thorough patch below.

> Curiously, replacing the last line by C-c C-k kills the draft but 
> doesn't change the frame (note that I applied the patch). I deduce that 
> rmail-mail-return is not called by C-c C-k... Am I doing something 
> wrong?

It looks like "C-c C-k" (implemented in message.el) was not intended
to return to the original buffer.

diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index d422383..437f120 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -3684,7 +3684,12 @@ rmail-start-mail
 				   other-headers)
   (let ((switch-function
 	 (cond (same-window nil)
-	       (rmail-mail-new-frame 'switch-to-buffer-other-frame)
+	       (rmail-mail-new-frame
+                (progn
+                  ;; Record the frame from which we invoked this command.
+                  (modify-frame-parameters (selected-frame)
+				           '((rmail-orig-frame . t)))
+                  'switch-to-buffer-other-frame))
 	       (t 'switch-to-buffer-other-window)))
 	yank-action)
     (if replybuffer
@@ -3714,6 +3719,11 @@ rmail-start-mail
 	  (modify-frame-parameters (selected-frame)
 				   '((mail-dedicated-frame . t)))))))
 
+(defun rmail--find-orig-rmail-frame ()
+  (car (filtered-frame-list
+        (lambda (frame)
+          (eq (frame-parameter frame 'rmail-orig-frame) t)))))
+
 (defun rmail-mail-return (&optional newbuf)
   "Try to return to Rmail from the mail window.
 If optional argument NEWBUF is specified, it is the Rmail buffer
@@ -3755,9 +3765,19 @@ rmail-mail-return
    ;; probably wants to delete it now.
    ((display-multi-frame-p)
     (delete-frame))
-   ;; The previous frame is where normally they have the Rmail buffer
-   ;; displayed.
-   (t (other-frame -1))))
+   (t
+    ;; Try to find the original Rmail frame and make it the top frame.
+    (let ((fr (selected-frame))
+          (orig-fr (rmail--find-orig-rmail-frame)))
+      (if orig-fr
+          (progn
+            (modify-frame-parameters orig-fr '((rmail-orig-frame . nil)))
+            (select-frame-set-input-focus orig-fr))
+        ;; If we cannot find the frame from which we started, punt, and
+        ;; display the previous frame, which is where they normally have
+        ;; the Rmail buffer displayed.
+        (other-frame -1))
+      (delete-frame fr)))))
 
 (defun rmail-mail ()
   "Send mail in another window.





  reply	other threads:[~2024-04-20 11:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 22:49 bug#69738: [BUG] rmail-mail-new-frame doesn't delete the new frame after composing the message on Emacs 29.2 rameiko87
2024-03-12 13:54 ` Eli Zaretskii
2024-03-21  8:57   ` Eli Zaretskii
2024-04-13 17:44 ` bug#69738: Followup rameiko87
2024-04-14  9:44   ` Eli Zaretskii
2024-04-14 16:14     ` rameiko87
2024-04-14 16:30       ` Eli Zaretskii
2024-04-14 17:47         ` rameiko87
2024-04-14 17:55           ` rameiko87
2024-04-14 18:50             ` Eli Zaretskii
2024-04-14 18:49           ` Eli Zaretskii
2024-04-15 10:15             ` rameiko87
2024-04-20 11:11               ` Eli Zaretskii [this message]
2024-05-04  9:37                 ` Eli Zaretskii
2024-05-06 19:12                   ` rameiko87

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wmos8f0o.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=69738@debbugs.gnu.org \
    --cc=rameiko87@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).