Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mu4e-message-kill-buffer doesn't restore previous window configuration #2600

Closed
thierryvolpiatto opened this issue Nov 19, 2023 · 24 comments
Closed
Labels
bug mu4e specific for mu4e needinfo

Comments

@thierryvolpiatto
Copy link
Contributor

Describe the bug

When killing composition buffer (C-c C-k) previous window configuration is not restored.

How to Reproduce

  1. Open an Email from mu4e headers buffer.
    You have now two windows, the headers window and the view buffer where your mail is.
  2. Hit "W" or "R" to reply, you have now the headers window (same as before) and in place of the view buffer the composition buffer.
  3. Change your mind and hit C-c C-k.
    You have now only the headers window. This because mu4e-message-kill-buffer set the view buffer before killing the composition buffer and also it check for windows that are no more existing.

What is expected is to be back to 1) when hitting C-c C-k.

The following patch is fixing it:

diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el
index 7ceb365b..836d2072 100644
--- a/mu4e/mu4e-compose.el
+++ b/mu4e/mu4e-compose.el
@@ -461,14 +461,14 @@ It attempts to restore some mu4e window layout after killing the
 compose-buffer."
   (interactive)
   (let ((win (selected-window))
-        (view (mu4e-get-view-buffer))
+        ;; `mu4e-get-view-buffer' makes the view buffer current.
+        (view (save-selected-window (mu4e-get-view-buffer)))
         (hdrs (mu4e-get-headers-buffer)))
     (message-kill-buffer)
-    (when (window-live-p win) (delete-window win))
     ;; try to go back to some mu window if its live; otherwise do nothing.
-    (if (and (buffer-live-p view) (window-live-p (get-buffer-window view)))
+    (if (buffer-live-p view)
         (switch-to-buffer view)
-      (when (and (buffer-live-p hdrs) (window-live-p (get-buffer-window hdrs)))
+      (when (buffer-live-p hdrs)
         (switch-to-buffer hdrs)))))
 
 ;;; Crypto

Environment

LinuxMint and Emacs-29.1

Checklist

  • [X ] you are running either an 1.8.x/1.10.x release or master (otherwise please upgrade)
  • [ X] you can reproduce the problem without 3rd party extensions (including Doom/Evil, various extensions etc.)
  • [ X] you have read all of the above

Please make sure you all items in the checklist are set/met before filing the ticket. Thank you!

@thierryvolpiatto thierryvolpiatto added bug mu4e specific for mu4e new labels Nov 19, 2023
@thierryvolpiatto
Copy link
Contributor Author

I guess there is a similar issue as well when sending mail (instead of C-c C-k), but this time I always end up with 3 windows:
The headers window, a window handling previous buffer used before opening Mu4e, and the view buffer.
Didn't find how to fix it yet.

@thierryvolpiatto
Copy link
Contributor Author

I guess there is a similar issue as well when sending mail (instead of C-c C-k), but this time I always end up with 3 windows:
The headers window, a window handling previous buffer used before opening Mu4e, and the view buffer.

This happen after tag 1.11.24, I will try to bissect further to find the offending commit.

@thierryvolpiatto
Copy link
Contributor Author

Culprit is commit 8abf098

@djcb
Copy link
Owner

djcb commented Nov 21, 2023

Ah, thanks for checking.

There's a bit of messy massaging around the way message does its thing, and there is still some more to do...

@djcb djcb removed the new label Nov 21, 2023
@djcb
Copy link
Owner

djcb commented Nov 30, 2023

Ah, hadn't even noticed the new behavior. Anyway, the proposed change seems to do the job, I'll push a fix soon. Thanks!

@djcb djcb closed this as completed in 18efe9a Dec 1, 2023
@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Dec 25, 2023 via email

@djcb djcb reopened this Dec 29, 2023
@djcb
Copy link
Owner

djcb commented Dec 29, 2023

I'll reopen this one...

@djcb
Copy link
Owner

djcb commented Feb 7, 2024

FWIW, things work fine for me when sending / cancelling a message composition if I have just the headers / view message (ie., the canceled composition is replaced with the message-view I started with)

However, when there's another window, cancelling the composition strangely changes the window to the headers view (so I have two now). Have to find what causes the difference.

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Feb 8, 2024 via email

@djcb
Copy link
Owner

djcb commented Feb 18, 2024

Hmm, can't reproduce the erroneous behavior today. Perhaps something changed in emacs itself?

Ie., I have a headers-view window and an unrelated window. In the headers-view, I view, then reply to some message R; then close it C-c C-k. And we're back at the beginning. Not sure what changed.

There's still some issue with deleting frames though.

@djcb
Copy link
Owner

djcb commented Apr 16, 2024

Following the steps:

How to Reproduce

    Open an Email from mu4e headers buffer.
    You have now two windows, the headers window and the view buffer where your mail is.
    Hit "W" or "R" to reply, you have now the headers window (same as before) and in place of the view buffer the composition buffer.
    Change your mind and hit C-c C-k.
    You have now only the headers window. This because mu4e-message-kill-buffer set the view buffer before killing the composition buffer and also it check for windows that are no more existing.

this works fine for me (with 1.12.4). For you too?

@djcb djcb added the needinfo label Apr 16, 2024
@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 16, 2024 via email

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 16, 2024 via email

@djcb
Copy link
Owner

djcb commented Apr 16, 2024

Hmm, trying to repro the original "How to reproduce" scenario here.

Start emacs/mu4e (change paths as needed):

 emacs -Q --eval "(progn (add-to-list 'load-path \"~/Sources/mu/build/mu4e\") (setq mu4e-mu-binary \"~/Sources/mu/build/mu/mu\") (require 'mu4e) (mu4e))"

bu to go to some unread mails. Press R. Press C-c C-k works as expected.

I tried with emacs master and emacs 28.2; both work for me.

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 16, 2024 via email

@djcb
Copy link
Owner

djcb commented Apr 16, 2024

Yeah, same in that case; two windows, I press R, the view window is replaced by the composition window. I press C-c C-k, and the composition goes away and we're back at the view window, just like before pressing R.

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 18, 2024 via email

@djcb
Copy link
Owner

djcb commented Apr 18, 2024

Both sending and cancelling messages work fine for me, if it were "really annoying" surely I'd notice.

mu4e is at the mercy of what gnus gives up and the abstraction is not fully watertight, so perhaps you found something that influences things in a way that bubbles up.

I'm planning to rework the composition code a bit, so whatever your advising likely will go away. But hopefully it's not necessary anymore.

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 18, 2024 via email

@theophilusx
Copy link

Another data point regarding new behaviour in latest version.

I'm often seeing a read/view buffer pop back up without being requested. I think I've narrowed down the exact steps required to reproduce.

  1. Open my inbox (SPC j i in my case)
  2. Move to some message in the header view
  3. Hit on the message to read it
  4. Hit 'q' whil in the message buffer to exist and return to the header view
  5. Mark the message in some way i.e. 'd' to delete it
  6. Hit 'x' to apply marks

at this point, the view buffer for the previously viewed message pops up again.

I then hit 'q' to close the view buffer and then hit 'q' again to exit the headers view and return to the main mu4e window.

I'm running Emacs 30.0.50 on Fedora 39 under either hyprland (Wayland) or i3 (X).
I use meow.el, so modal editing.
I have no frame or window settings in Emacs and don't use anything like winnum or any other window management packages. Essentially, I start emacs as a daemon and then use emacsclient full scren frame. I have a dedicatged virtual desktop for mu4e. When I want to do other stuff, I move desktop workspace (virtual desktop) and open a new frame.

The popping up of the view buffer after applying marks is a little irritating, but no big deal. It is behaviour I only noticed fairly recently. However, as I run both Emacs and mu4e from git HEAD, really don't know if this new behaviour is due to changes in Emacs or changes in mu4e.

Note that I see the same behaviour with Emacs build with standard GTK (for X) and with the pure or pgtk variant (for Wayland).

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented Apr 19, 2024 via email

@djcb
Copy link
Owner

djcb commented Apr 19, 2024

Yeah, I'm trying to make that convoluted path a bit less so; however, fundamentally mu4e handles buffer display, and it takes that task over from the Gnus code. That way, it can display buffers the way that mu4e does that, and support display-buffer etc.

Anyway, let's see how things work after changes.

@thierryvolpiatto
Copy link
Contributor Author

thierryvolpiatto commented May 2, 2024 via email

@djcb
Copy link
Owner

djcb commented Oct 28, 2024

Closing this ticket, I think it's about as good as it gets now :-) Thank all for the inputs.

@djcb djcb closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mu4e specific for mu4e needinfo
Projects
None yet
Development

No branches or pull requests

3 participants