From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69738: Followup Date: Sat, 04 May 2024 12:37:32 +0300 Message-ID: <86a5l5hq8z.fsf@gnu.org> References: <4a0215b2e7bb416cf352e867183f745a@posteo.net> <1ed9ea789788d6a6450c86920199b6c6@posteo.net> <8634ronurh.fsf@gnu.org> <86bk6bnbzl.fsf@gnu.org> <867cgzn5jw.fsf@gnu.org> <4d7b2d2317ad9512628fbd2725f33d8b@posteo.net> <86wmos8f0o.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4817"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69738@debbugs.gnu.org To: rameiko87@posteo.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 04 11:39:08 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s3BrH-0000xH-G3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 May 2024 11:39:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3Bqr-0007Ef-Eg; Sat, 04 May 2024 05:38:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3Bqp-0007Dd-OP for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 05:38:39 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3Bqp-0002AL-Ey for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 05:38:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s3BrC-00005w-4h for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 05:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 May 2024 09:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69738 X-GNU-PR-Package: emacs Original-Received: via spool by 69738-submit@debbugs.gnu.org id=B69738.1714815489343 (code B ref 69738); Sat, 04 May 2024 09:39:02 +0000 Original-Received: (at 69738) by debbugs.gnu.org; 4 May 2024 09:38:09 +0000 Original-Received: from localhost ([127.0.0.1]:52382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3BqK-00005S-Jg for submit@debbugs.gnu.org; Sat, 04 May 2024 05:38:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3BqG-00004x-Ls for 69738@debbugs.gnu.org; Sat, 04 May 2024 05:38:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3Bpo-00023L-1Q; Sat, 04 May 2024 05:37:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ZJ46TPlz+eBV9qC3vGQO2uRtyxM/dt68FVBFkHSpMY4=; b=g1f3+jZuVg4S pzDyRCbMH1+d2tRpSZqN43kGbr5pHCulZJZ8u8B31qq4SoXF+YOv6xjWxDaINMlugUEFcjqNh1Faa 5InVEq36r12rdOhpkA9Eh2e1G35iTMyQwh3AbMajinZkCn1YUVM+p1xxP6+SDniQeamYdyQ8rPDuj r/3RfNBZ6Zsg/Ak84E0sZXfKgm279rLPuQ5ptB33ZmqRKqz1xEubJV0QWLybfEHCjd8X0QeXd7Y/W jzdZ1qb1cifEiBWnUP8jLUitixGGVCtlB9BnU27CBM7HytVJXN181JLmEGZ/vTZ+L+uS6rUi7dlGv 8lD7BT8Fl9HGwEH1ohmiCA==; In-Reply-To: <86wmos8f0o.fsf@gnu.org> (message from Eli Zaretskii on Sat, 20 Apr 2024 14:11:51 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284410 Archived-At: Ping! Could you please try the patch I propose below? > Cc: 69738@debbugs.gnu.org > Date: Sat, 20 Apr 2024 14:11:51 +0300 > From: Eli Zaretskii > > > 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. > > > >