Skip to content

mu4e: Fix failure to start org-msg-edit-mode when editing drafts#195

Closed
Ndot wants to merge 1 commit intojeremy-compostella:masterfrom
Ndot:fix-edit-draft-with-subject
Closed

mu4e: Fix failure to start org-msg-edit-mode when editing drafts#195
Ndot wants to merge 1 commit intojeremy-compostella:masterfrom
Ndot:fix-edit-draft-with-subject

Conversation

@Ndot
Copy link
Copy Markdown

@Ndot Ndot commented Sep 24, 2024

[mu4e] Editing a draft message with a subject fails. In org-msg-post-setup when calling (org-msg-mua-call 'article-htmlp) it fails with "No message at point" from mu4e-message-at-point.

To solve this we advice mu4e-compose-edit and set a flag that we can check in org-msg-post-setup. This check is setup using a MUA call, although this is only implemented for mu4e. If this is need for other backends they need to implement the predicate and clear draft flag functions.

Comment thread org-msg.el
(remove-hook 'gnus-message-setup-hook 'org-msg-store-mml-buffers)
(advice-remove 'gnus-icalendar-send-buffer-by-mail 'org-msg-inhibited)))

(defvar org-msg--mu4e-message-draft-p nil)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it be a buffer local variable ?

Copy link
Copy Markdown
Author

@Ndot Ndot Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but I checked just to be sure, and it can't be local.

The variable is set either on "mu4e:headers" or "mu4e:view" buffer before mu4e-compose-edit is called, and than we check the variable in org-msg-post-setup by this time we are in the "mu4e:compose" buffer. If we set this variable to local it will always return nil.

Comment thread org-msg.el
"Returns `t' if the message being processed is a draft."
org-msg--mu4e-message-draft-p)

(defun org-msg-clear-message-draft-flag-mu4e ()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a lambda function instead ?

Copy link
Copy Markdown
Author

@Ndot Ndot Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I not sure I understand.

Those two functions are called using org-msg-mua-call like this:

(org-msg-mua-call 'message-draft-p)
(org-msg-mua-call 'clear-message-draft-flag)

Not sure how I can use a lambda function with org-msg-mua-call?


I originally had only one function to return the predicate and clear the flag, but for the sake of readability
and to keep matters separated I opted for two function, it makes the purpose of each function clearer.

Comment thread org-msg.el Outdated
(unless (eq major-mode 'org-msg-edit-mode)
(message-goto-body)
(let* ((type (cond ((not (org-msg-message-fetch-field "subject")) 'new)
(let* ((type (cond ((org-msg-mua-call 'message-draft-p (lambda () nil)) 'new)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that you need to pass a default.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct I misread org-msg-mua-call I thought it would error but it just returns nil.
Updated the branch and removed the default argument.

Editing a draft message with a subject fails. In `org-msg-post-setup`
when calling `(org-msg-mua-call 'article-htmlp)` it fails with "No
message at point" from `mu4e-message-at-point`.

To solve this we advice `mu4e-compose-edit` and set a flag that we can
check in `org-msg-post-setup`. This check is setup using a MUA call,
although this is only implemented for mu4e. If this is need for other
backends they need to implement the predicate and clear draft flag
functions.
@danielfleischer
Copy link
Copy Markdown
Contributor

Please see if #203 is enough to solve the problem.

@cjennings
Copy link
Copy Markdown
Collaborator

Thank you for identifying the issue and contributing to org-msg. This issue was addressed in PR #205 which was just merged. PR #205. Closing as resolved by #205.

@cjennings cjennings closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants