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, 20 Apr 2024 14:11:51 +0300 Message-ID: <86wmos8f0o.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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39310"; 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 Apr 20 13:13:00 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 1ry8eS-000A11-F2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 13:13:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ry8eH-0005DU-N2; Sat, 20 Apr 2024 07:12:49 -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 1ry8eF-0005DK-UP for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 07:12:47 -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 1ry8eF-0007qR-MY for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 07:12:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ry8eU-0006fl-2r for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 07:13: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, 20 Apr 2024 11:13: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.171361155525431 (code B ref 69738); Sat, 20 Apr 2024 11:13:02 +0000 Original-Received: (at 69738) by debbugs.gnu.org; 20 Apr 2024 11:12:35 +0000 Original-Received: from localhost ([127.0.0.1]:35785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry8do-0006Zt-1G for submit@debbugs.gnu.org; Sat, 20 Apr 2024 07:12:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry8dj-0006Yx-9I for 69738@debbugs.gnu.org; Sat, 20 Apr 2024 07:12:18 -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 1ry8dO-0007hZ-Vt; Sat, 20 Apr 2024 07:11:54 -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=fjeRs4j5TsuFXRudr4gSebEMhAi+BBiLce1Rfmru7UI=; b=M90POCIIdc07 hbi3N9e+dqefdWqjLnLh+EOhmGf4foUa7GfP0zk389oL02R0a50+EN8Ut11OOR5XWhF7RmZQ+mRQj NPhEMTf0LjBHwdtT/1s0/W0i+aXC4XV3a6DDrno5wGBWE+q/soQ9m0ZiC+W4QeKmozRGiaH+1CgcN Pst4FrYsCAGEfEKRHkBQgv+SlwJQgvu27PJ11YdqP1SIdT18VQMM53MqeUiJlQx4VOr1wVtSqX1vv Asjfl7XKGrhjj6K4HTlocfN73Ft8d3mga7AsPvhk0ci3V7tNkFaX0BZI54FIrE0rDRlZwVXJjlthA 2oZVMJo63JeAuYMNVSyJiQ==; In-Reply-To: <4d7b2d2317ad9512628fbd2725f33d8b@posteo.net> (rameiko87@posteo.net) 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:283731 Archived-At: > 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.