diff options
author | yoctocell <public@yoctocell.xyz> | 2021-01-04 11:46:18 +0100 |
---|---|---|
committer | yoctocell <public@yoctocell.xyz> | 2021-01-04 11:46:18 +0100 |
commit | 7d9b53a6be90222b7b36e6bafac112a030c6dcc5 (patch) | |
tree | cbaa0cf9c451a9cbc4b6a9e42390c12b220ce421 /git-email.el | |
parent | bd4202dedff8e152197fd669447e493844bb4435 (diff) |
Create a message for each selected file
Add helper functions to get a list of marked files, or the file under
point.
git-email-send-email => git-email--compose-email
* git-email.el (git-email-send-email):
(git-email--dired):
(git-email--vc-dir):
(git-email--get-filenames):
Diffstat (limited to 'git-email.el')
-rw-r--r-- | git-email.el | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/git-email.el b/git-email.el index 5a12e1c..716c37d 100644 --- a/git-email.el +++ b/git-email.el @@ -108,11 +108,45 @@ If the header is not found, return an empty string." (- (re-search-forward "\n\n") 1) (point-max)))) -(defun git-email-send-email (patch-file) - "Given a PATCH-FILE, send an email. +(defun git-email--dired () + "Return filenames for marked files in `dired'. +If no marks are found, return the filename at point." + (delq nil + (mapcar + (lambda (f) (if (file-directory-p f) nil f)) + (dired-map-over-marks (dired-get-filename) nil)))) + +(defun git-email--vc-dir () + "Return filenames for marked files in `vc-dir'. +If no marks are found, return the filename at point." + (let* ((marked-files (vc-dir-marked-files)) + (files (if marked-files + marked-files + (list (vc-dir-current-file))))) + files)) + +(defun git-email--get-filenames () + "Return filenames for marked files in `vc-dir'. +If no marks are found, return the filename at point." + (cond ((eq major-mode 'dired-mode) + (git-email--dired)) + ((eq major-mode 'vc-dir-mode) + ;; We want to display the cover letter first + (nreverse (vc-dir-marked-files))) + (t + (message "Not a supported major mode")))) + +(defun git-email-send-email () + "Send patch(es) to someone." + (interactive) + (let ((files (git-email--get-filenames))) + (dolist (file files) + (git-email--compose-email file)))) + +(defun git-email--compose-email (patch-file) + "Given a PATCH-FILE, compose an email. Extracts the relevant headers and the diff from the PATCH-FILE and inserts them into the message buffer." - (interactive) (let* ((default-directory (cdr (project-current))) (headers (git-email--extract-headers patch-file)) (used-headers (seq-filter |