mu icon indicating copy to clipboard operation
mu copied to clipboard

[mu bug] avoid `find-file`

Open malb opened this issue 1 year ago • 1 comments

mu4e-compose-edit calls find-file which will display the buffer. I think find-file-noselect should be called instead. The former displays the buffer, the latter does not. At the point it is called, there does not appear to be a good way to decide on how to display the buffer.

malb avatar Feb 29 '24 11:02 malb

I'm using

     (mu4e--compose-setup
      'edit
      (lambda (parent)
-       (find-file (plist-get parent :path))
+       (let ((buf (find-file-noselect (plist-get parent :path))))
+         (with-current-buffer buf
+           (mu4e-compose-mode)
+           (display-buffer buf)))

but I'm not sure this is a great "fix".

malb avatar Feb 29 '24 11:02 malb

FWIW, I still have to patch this one to

(defun mu4e-compose-edit()
  "Edit an existing draft message."
  (interactive)
  (let* ((msg (mu4e-message-at-point)))
    (unless  (member 'draft (mu4e-message-field msg :flags))
      (mu4e-warn "Cannot edit non-draft messages"))
    (mu4e--compose-setup
     'edit
     (lambda (parent)
       (let ((buf (find-file-noselect (plist-get parent :path))))
         (with-current-buffer buf
           (mu4e--delimit-headers)
           (mu4e-compose-mode))
         (display-buffer buf))))))
  1. Based on this calling switch-to-buffer in code is "against the rules" and indeed garbles up my window managment.
  2. I need to add (mu4e-compose-mode) to trigger my display-buffer-alist logic.

Let me stress once more that this is somewhat a "me" problem, i.e. I know I'm trying to bend mu4e to my will in a way you don't plan for.

malb avatar Apr 14 '24 15:04 malb