-
Notifications
You must be signed in to change notification settings - Fork 391
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
Ensure mu4e-compose-pre-hook has access to parent message and compose type #2716
Open
milouse
wants to merge
2
commits into
djcb:master
Choose a base branch
from
milouse:fix/mu4e-compose-pre-hook
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,7 +494,7 @@ Creates a buffer NAME and returns it." | |
|
||
(defmacro mu4e--validate-hidden-buffer (&rest body) | ||
"Macro to evaluate BODY and asserts that it yields a valid buffer. | ||
Where valid means that it is a live an non-active buffer. | ||
Where valid means that it is a live and a non-active buffer. | ||
Returns said buffer." | ||
`(let ((buf (progn ,@body))) | ||
(cl-assert (buffer-live-p buf)) | ||
|
@@ -556,12 +556,14 @@ while in a buffer with the to-be-forwarded/replied-to message." | |
"Message headers to hide when composing. | ||
This is mu4e's version of `message-hidden-headers'.") | ||
|
||
(defun mu4e--prepare-draft (&optional parent) | ||
(defun mu4e--prepare-draft (compose-type &optional parent) | ||
"Get ready for message composition. | ||
PARENT is the parent message, if any." | ||
(cl-assert (member compose-type '(reply forward edit new))) | ||
(cl-assert (eq (if parent t nil) | ||
(if (member compose-type '(reply forward)) t nil))) | ||
(unless (mu4e-running-p) (mu4e 'background)) ;; start if needed | ||
(mu4e--context-autoswitch parent mu4e-compose-context-policy) | ||
(run-hooks 'mu4e-compose-pre-hook)) | ||
(mu4e--context-autoswitch parent mu4e-compose-context-policy)) | ||
|
||
(defun mu4e--prepare-draft-headers (compose-type) | ||
"Add extra headers for message based on COMPOSE-TYPE." | ||
|
@@ -576,16 +578,6 @@ PARENT is the parent message, if any." | |
(defun mu4e--prepare-draft-buffer (compose-type parent) | ||
"Prepare the current buffer as a draft-buffer. | ||
COMPOSE-TYPE and PARENT are as in `mu4e--draft'." | ||
(cl-assert (member compose-type '(reply forward edit new))) | ||
(cl-assert (eq (if parent t nil) | ||
(if (member compose-type '(reply forward)) t nil))) | ||
;; remember some variables, e.g for user hooks. These are permanent-local | ||
;; hence survive the mode-switch below (we do this so these useful vars are | ||
;; available in mode-hooks. | ||
(setq-local | ||
mu4e-compose-parent-message parent | ||
mu4e-compose-type compose-type) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve cut this part in 2 block:
|
||
;; draft path | ||
(unless (eq compose-type 'edit) | ||
(set-visited-file-name ;; make it a draft file | ||
|
@@ -709,7 +701,7 @@ it must be nil. | |
After this, user is presented with a message composition buffer. | ||
|
||
Returns the new buffer." | ||
(mu4e--prepare-draft parent) | ||
(mu4e--prepare-draft compose-type parent) | ||
;; evaluate BODY; this must yield a hidden, live buffer. This is evaluated in | ||
;; a temp buffer with contains the parent-message, if any. if there's a | ||
;; PARENT, load the corresponding message into a temp-buffer before calling | ||
|
@@ -718,6 +710,13 @@ Returns the new buffer." | |
(oldframe (selected-frame)) | ||
(oldwinconf (current-window-configuration))) | ||
(with-temp-buffer | ||
;; remember some variables, e.g for user hooks. These are permanent-local | ||
;; hence survive the mode-switch below (we do this so these useful vars are | ||
;; available in mode-hooks. | ||
(setq-local | ||
mu4e-compose-parent-message parent | ||
mu4e-compose-type compose-type) | ||
(run-hooks 'mu4e-compose-pre-hook) | ||
;; provide a temp buffer so the compose-func can do its thing | ||
(setq draft-buffer (mu4e--validate-hidden-buffer (funcall compose-func))) | ||
(with-current-buffer draft-buffer | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djcb This is the point I’m the less sure about. Do not hesitate to comment if this is completely wrong.