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 rfe] Let display-buffer-alist dictate compose buffers #2636

Closed
malb opened this issue Feb 26, 2024 · 3 comments
Closed

[mu4e rfe] Let display-buffer-alist dictate compose buffers #2636

malb opened this issue Feb 26, 2024 · 3 comments
Labels
mu4e specific for mu4e rfe

Comments

@malb
Copy link
Contributor

malb commented Feb 26, 2024

Is your feature request related to a problem? Please describe.

At present, I don't see how I can pass e.g. frame parameters to the mu4e-compose frame created by mu4e.

Describe the solution you'd like

An option to let display-buffer-alist do its thing. I suggest an additional option for mu4e-compose-switch: display-buffer-alist which translates to (mu4e--compose-switch-function) becoming a noop. In addition, I think switch-to-buffer in mu4e--compose-setup should be replaced by display-buffer.

Describe alternatives you've considered

I've patched this behaviour as follows:

Additional context

diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el
index 082665a0..2830f9c9 100644
--- a/mu4e/mu4e-compose.el
+++ b/mu4e/mu4e-compose.el
@@ -776,13 +776,13 @@ Optionally, SWITCH determines how to find a buffer for the message
     (mu4e--context-autoswitch parent mu4e-compose-context-policy)
     (with-current-buffer
         (mu4e--compose-setup-buffer compose-type compose-func parent)
-      (funcall (or switch (mu4e--compose-switch-function)) (current-buffer))
+      ;; (funcall (or switch (mu4e--compose-switch-function)) (current-buffer))
       (unless (eq compose-type 'edit)
         (set-visited-file-name ;; make it a draft file
          (mu4e--draft-message-path (mu4e--message-basename) parent)))
       (mu4e--compose-setup-post compose-type parent)
       (setq buf (current-buffer))
-      (switch-to-buffer buf)
+      (display-buffer buf)
       (let* ((msgframe (selected-frame))
              (actions (list
                        (lambda () ;; kill frame when it was created for this

I then use:

(defun malb/frame-dispatch (buffer alist)
  "Assigning buffers to frames."
  (cond
   ;; a mu4e compose buffer
   ((eq (buffer-local-value 'major-mode buffer) 'mu4e-compose-mode)
    (malb/display-mu4e-draft-buffer buffer alist)
    nil)

   ((eq (buffer-local-value 'major-mode (current-buffer)) 'mu4e-compose-mode)
    (malb/switch-away-from-special-and-tab (string-match-p ".*helm.*" (buffer-name buffer)))
    nil)

   ;; an mu4e buffer
   ((or (malb/mu4e-buffer-p buffer nil))
    (malb/switch-to-mu4e)
    nil)

   ;; this is not a mu4e buffer but we’re in the mu4e frame
   ((and (string-match "*mu4e*" (frame-parameter nil 'name))
         (not (malb/mu4e-buffer-p buffer nil))
         (not (malb/regexp-match-p malb/mu4e-buffer-allowed-regexps (buffer-name buffer))))
    (malb/switch-away-from-special-and-tab (string-match-p ".*helm.*" (buffer-name buffer)))
    nil)

   (t nil)))

and

(defun malb/display-mu4e-draft-buffer (buffer alist)
  (display-buffer-pop-up-frame buffer
                               '((window-parameters . ((no-other-window . t)))
                                 (dedicated . t)
                                 (pop-up-frame-parameters . ((width . 82)
                                                             (malb/special-frame . t))))))

with the desired effect.

See https://github.com/malb/emacs.d/blob/master/malb.org#dispatch-buffers-to-frames and https://github.com/malb/emacs.d/blob/master/malb.org#window-management-1

@malb malb added mu4e specific for mu4e new rfe labels Feb 26, 2024
@djcb djcb removed the new label Feb 28, 2024
@djcb
Copy link
Owner

djcb commented Feb 28, 2024

I suppose when you let mu4e create the frame, it's a little too late to influence it; but gess what you could do is leave mu4e-compose-switch at its default, and handle the frame creation yourself with your display-buffer-alist customization?

@malb
Copy link
Contributor Author

malb commented Feb 28, 2024

I don't think I can do this at present. The buffer is currently shown before being in mu4e-compose-mode (in mu4e--compose-setup-post) and I thus struggle to come up with a rule to "catch it". If I could make mu4e--compose-switch-function a noop then I know how to make it work.

@malb
Copy link
Contributor Author

malb commented Mar 3, 2024

Resolved with 20878c8

@malb malb closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mu4e specific for mu4e rfe
Projects
None yet
Development

No branches or pull requests

2 participants