Skip to content

Conversation

Ndot
Copy link

@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.

(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)

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
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.

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

(defun org-msg-clear-message-draft-flag-mu4e ()

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
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.

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)

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
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
Contributor

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

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.

3 participants