From fdf112b63eb755fcaa5138567ed0428eea3957ff Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 09:17:44 -0700 Subject: update version in mailscripts.el Signed-off-by: Sean Whitton --- mailscripts.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index f0002fc..3d3a584 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,7 +1,7 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton -;; Version: 0.11 +;; Version: 0.12 ;; Package-Requires: (notmuch) ;; Copyright (C) 2018 Sean Whitton -- cgit v1.2.3 From 8d2dcb9d14a681c3ba86dc2f67756a5619f4d10d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 09:52:46 -0700 Subject: mailscripts.el: add mailscripts-extract-patches-branch-prefix Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index 149b4e1..6f57add 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium * email-print-mime-structure: add capability to decrypt message parts (Closes: #943959). Thanks to Daniel Kahn Gillmor for the patch series. + * mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom. -- Sean Whitton Fri, 01 Nov 2019 20:38:07 -0700 diff --git a/mailscripts.el b/mailscripts.el index 3d3a584..a2ec230 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -4,7 +4,7 @@ ;; Version: 0.12 ;; Package-Requires: (notmuch) -;; Copyright (C) 2018 Sean Whitton +;; Copyright (C) 2018, 2019 Sean Whitton ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -23,6 +23,16 @@ (require 'notmuch) +(defgroup mailscripts nil + "Customisation of functions in the mailscripts package.") + +(defcustom mailscripts-extract-patches-branch-prefix nil + "Prefix for git branches created by functions which extract patch series. + +E.g. `mailed/'." + :type 'string + :group 'mailscripts) + ;;;###autoload (defun notmuch-slurp-debbug (bug &optional no-open) "Slurp Debian bug with bug number BUG and open the thread in notmuch. @@ -54,14 +64,20 @@ threads to the notmuch-extract-patch(1) command." (interactive "Dgit repo: \nsnew branch name: ") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) - (call-process-shell-command - (format "git checkout -b %s" - (shell-quote-argument branch))) + (mailscripts--check-out-branch branch) (shell-command (format "notmuch-extract-patch %s | git am" (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) +(defun mailscripts--check-out-branch (branch) + (call-process-shell-command + (format "git checkout -b %s" + (shell-quote-argument + (if mailscripts-extract-patches-branch-prefix + (concat mailscripts-extract-patches-branch-prefix branch) + branch))))) + (provide 'mailscripts) ;;; mailscripts.el ends here -- cgit v1.2.3 From cb53ee3309fb20492bdb2d43c4596ed507140701 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 10:06:39 -0700 Subject: mailscripts.el: add notmuch-extract-thread-patches-projectile Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index 6f57add..52c4282 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium (Closes: #943959). Thanks to Daniel Kahn Gillmor for the patch series. * mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom. + * mailscripts.el: add notmuch-extract-thread-patches-projectile command. -- Sean Whitton Fri, 01 Nov 2019 20:38:07 -0700 diff --git a/mailscripts.el b/mailscripts.el index a2ec230..bcdc0ad 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -2,7 +2,7 @@ ;; Author: Sean Whitton ;; Version: 0.12 -;; Package-Requires: (notmuch) +;; Package-Requires: (notmuch projectile) ;; Copyright (C) 2018, 2019 Sean Whitton @@ -22,6 +22,7 @@ ;;; Code: (require 'notmuch) +(require 'projectile) (defgroup mailscripts nil "Customisation of functions in the mailscripts package.") @@ -70,6 +71,12 @@ threads to the notmuch-extract-patch(1) command." (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) +;;;###autoload +(defun notmuch-extract-thread-patches-projectile () + "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." + (interactive) + (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) + (defun mailscripts--check-out-branch (branch) (call-process-shell-command (format "git checkout -b %s" @@ -78,6 +85,12 @@ threads to the notmuch-extract-patch(1) command." (concat mailscripts-extract-patches-branch-prefix branch) branch))))) +(defun mailscripts--projectile-repo-and-branch (f) + (let ((repo (projectile-completing-read + "Select projectile project: " projectile-known-projects)) + (branch (completing-read "Branch name: " nil))) + (funcall f repo branch))) + (provide 'mailscripts) ;;; mailscripts.el ends here -- cgit v1.2.3 From 80bf3c2b53d7514b888cec7ca6fdb2f4e579269d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 12:06:40 -0700 Subject: mailscripts.el: add notmuch-extract-message-patches{,-projectile} Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index 52c4282..06e92e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium Thanks to Daniel Kahn Gillmor for the patch series. * mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom. * mailscripts.el: add notmuch-extract-thread-patches-projectile command. + * mailscripts.el: add notmuch-extract-message-patches{,-projectile} commands. -- Sean Whitton Fri, 01 Nov 2019 20:38:07 -0700 diff --git a/mailscripts.el b/mailscripts.el index bcdc0ad..09d213d 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -77,6 +77,35 @@ threads to the notmuch-extract-patch(1) command." (interactive) (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) +;;;###autoload +(defun notmuch-extract-message-patches (repo branch) + "Extract patches attached to current message to branch BRANCH in repo REPO. + +The target branch may or may not already exist. + +Patches are applied using git-am(1), so we only consider +attachments with filenames which look like they were generated by +git-format-patch(1)." + (interactive "Dgit repo: \nsnew branch name: ") + (with-current-notmuch-show-message + (let ((default-directory (expand-file-name repo)) + (mm-handle (mm-dissect-buffer))) + (mailscripts--check-out-branch branch) + (notmuch-foreach-mime-part + (lambda (p) + (let* ((disposition (mm-handle-disposition p)) + (filename (cdr (assq 'filename disposition)))) + (and filename + (string-match "^[0-9]+-.+\.\\(patch\\|diff\\|txt\\)$" filename) + (mm-pipe-part p "git am")))) + mm-handle)))) + +;;;###autoload +(defun notmuch-extract-message-patches-projectile () + "Like `notmuch-extract-message-patches', but use projectile to choose the repo." + (interactive) + (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) + (defun mailscripts--check-out-branch (branch) (call-process-shell-command (format "git checkout -b %s" -- cgit v1.2.3 From 3d33e7c0483bb9ab8de3ffd6a0372c8d2a0bffa0 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 12:33:25 -0700 Subject: make it possible to suppress prefixing to the branch name Signed-off-by: Sean Whitton --- mailscripts.el | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index 09d213d..d4d7e95 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -54,43 +54,49 @@ If NO-OPEN, don't open the thread." (notmuch-refresh-this-buffer))) ;;;###autoload -(defun notmuch-extract-thread-patches (repo branch) +(defun notmuch-extract-thread-patches (repo branch &optional no-prefix) "Extract patch series in current thread to branch BRANCH in repo REPO. +A prefix arg suppresses the effects of +`mailscripts-extract-patches-branch-prefix'. + The target branch may or may not already exist. See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." - (interactive "Dgit repo: \nsnew branch name: ") + (interactive "Dgit repo: \nsnew branch name: \nP") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) - (mailscripts--check-out-branch branch) + (mailscripts--check-out-branch branch no-prefix) (shell-command (format "notmuch-extract-patch %s | git am" (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) ;;;###autoload -(defun notmuch-extract-thread-patches-projectile () +(defun notmuch-extract-thread-patches-projectile (&optional no-prefix) "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." - (interactive) + (interactive "P") (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) ;;;###autoload -(defun notmuch-extract-message-patches (repo branch) +(defun notmuch-extract-message-patches (repo branch &optional no-prefix) "Extract patches attached to current message to branch BRANCH in repo REPO. +A prefix arg suppresses the effects of +`mailscripts-extract-patches-branch-prefix'. + The target branch may or may not already exist. Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." - (interactive "Dgit repo: \nsnew branch name: ") + (interactive "Dgit repo: \nsnew branch name: \nP") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) - (mailscripts--check-out-branch branch) + (mailscripts--check-out-branch branch no-prefix) (notmuch-foreach-mime-part (lambda (p) (let* ((disposition (mm-handle-disposition p)) @@ -101,16 +107,16 @@ git-format-patch(1)." mm-handle)))) ;;;###autoload -(defun notmuch-extract-message-patches-projectile () +(defun notmuch-extract-message-patches-projectile (&optional no-prefix) "Like `notmuch-extract-message-patches', but use projectile to choose the repo." - (interactive) + (interactive "P") (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) -(defun mailscripts--check-out-branch (branch) +(defun mailscripts--check-out-branch (branch no-prefix) (call-process-shell-command (format "git checkout -b %s" (shell-quote-argument - (if mailscripts-extract-patches-branch-prefix + (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) (concat mailscripts-extract-patches-branch-prefix branch) branch))))) -- cgit v1.2.3 From cccf4e3f80da4582c81b3a014d5726922a0a0c85 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 13:13:37 -0700 Subject: add possible 'vN-' prefix to git-format-patch(1) filename regexp Signed-off-by: Sean Whitton --- mailscripts.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index d4d7e95..d8f60a6 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -102,7 +102,8 @@ git-format-patch(1)." (let* ((disposition (mm-handle-disposition p)) (filename (cdr (assq 'filename disposition)))) (and filename - (string-match "^[0-9]+-.+\.\\(patch\\|diff\\|txt\\)$" filename) + (string-match + "^\\(v[0-9]+-\\)?[0-9]+-.+\.\\(patch\\|diff\\|txt\\)$" filename) (mm-pipe-part p "git am")))) mm-handle)))) -- cgit v1.2.3 From 34f83d0d1ce17e6ef05dfe16f9a70c937cf2df56 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 4 Nov 2019 15:34:15 -0700 Subject: thread no-prefix through the -projectile functions Signed-off-by: Sean Whitton --- mailscripts.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index d8f60a6..92cfe31 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -78,7 +78,8 @@ threads to the notmuch-extract-patch(1) command." (defun notmuch-extract-thread-patches-projectile (&optional no-prefix) "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." (interactive "P") - (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) + (mailscripts--projectile-repo-and-branch + 'notmuch-extract-thread-patches no-prefix)) ;;;###autoload (defun notmuch-extract-message-patches (repo branch &optional no-prefix) @@ -111,7 +112,8 @@ git-format-patch(1)." (defun notmuch-extract-message-patches-projectile (&optional no-prefix) "Like `notmuch-extract-message-patches', but use projectile to choose the repo." (interactive "P") - (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) + (mailscripts--projectile-repo-and-branch + 'notmuch-extract-message-patches no-prefix)) (defun mailscripts--check-out-branch (branch no-prefix) (call-process-shell-command @@ -121,11 +123,11 @@ git-format-patch(1)." (concat mailscripts-extract-patches-branch-prefix branch) branch))))) -(defun mailscripts--projectile-repo-and-branch (f) +(defun mailscripts--projectile-repo-and-branch (f &optional no-prefix) (let ((repo (projectile-completing-read "Select projectile project: " projectile-known-projects)) (branch (completing-read "Branch name: " nil))) - (funcall f repo branch))) + (funcall f repo branch no-prefix))) (provide 'mailscripts) -- cgit v1.2.3 From 23e42778e50eb030986ac6c5e98764f7775e359c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Nov 2019 20:31:50 -0700 Subject: tweak sample prefix Signed-off-by: Sean Whitton --- mailscripts.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index 92cfe31..6bc64bc 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -30,7 +30,7 @@ (defcustom mailscripts-extract-patches-branch-prefix nil "Prefix for git branches created by functions which extract patch series. -E.g. `mailed/'." +E.g. `email/'." :type 'string :group 'mailscripts) -- cgit v1.2.3 From 736064843a60ac1814da71550ae04c9673ed1e89 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Nov 2019 20:34:53 -0700 Subject: mailscripts.el: if user does not enter a branch name, use HEAD Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index dc13036..919eb1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium Thanks to Daniel Kahn Gillmor for the patch series. * mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom. * mailscripts.el: add notmuch-extract-thread-patches-projectile command. + * mailscripts.el: if user does not enter a branch name, use current HEAD. * mailscripts.el: add notmuch-extract-message-patches{,-projectile} commands. * elpa-mailscripts now depends on elpa-projectile. diff --git a/mailscripts.el b/mailscripts.el index 6bc64bc..db1cf94 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -65,7 +65,8 @@ The target branch may or may not already exist. See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." - (interactive "Dgit repo: \nsnew branch name: \nP") + (interactive + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) (mailscripts--check-out-branch branch no-prefix) @@ -93,7 +94,8 @@ The target branch may or may not already exist. Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." - (interactive "Dgit repo: \nsnew branch name: \nP") + (interactive + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) @@ -116,17 +118,20 @@ git-format-patch(1)." 'notmuch-extract-message-patches no-prefix)) (defun mailscripts--check-out-branch (branch no-prefix) - (call-process-shell-command - (format "git checkout -b %s" - (shell-quote-argument - (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) - (concat mailscripts-extract-patches-branch-prefix branch) - branch))))) + (unless (string= branch "") + (call-process-shell-command + (format "git checkout -b %s" + (shell-quote-argument + (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) + (concat mailscripts-extract-patches-branch-prefix branch) + branch)))))) (defun mailscripts--projectile-repo-and-branch (f &optional no-prefix) (let ((repo (projectile-completing-read "Select projectile project: " projectile-known-projects)) - (branch (completing-read "Branch name: " nil))) + (branch (completing-read + "Branch name (or leave blank to apply to current HEAD): " + nil))) (funcall f repo branch no-prefix))) (provide 'mailscripts) -- cgit v1.2.3 From 1f2438926be9b6d5365362dc95441956aa453331 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Nov 2019 20:41:04 -0700 Subject: Revert "thread no-prefix through the -projectile functions" This reverts commit 34f83d0d1ce17e6ef05dfe16f9a70c937cf2df56. Signed-off-by: Sean Whitton --- mailscripts.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index db1cf94..43d06d0 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -79,8 +79,7 @@ threads to the notmuch-extract-patch(1) command." (defun notmuch-extract-thread-patches-projectile (&optional no-prefix) "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." (interactive "P") - (mailscripts--projectile-repo-and-branch - 'notmuch-extract-thread-patches no-prefix)) + (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) ;;;###autoload (defun notmuch-extract-message-patches (repo branch &optional no-prefix) @@ -114,8 +113,7 @@ git-format-patch(1)." (defun notmuch-extract-message-patches-projectile (&optional no-prefix) "Like `notmuch-extract-message-patches', but use projectile to choose the repo." (interactive "P") - (mailscripts--projectile-repo-and-branch - 'notmuch-extract-message-patches no-prefix)) + (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) (defun mailscripts--check-out-branch (branch no-prefix) (unless (string= branch "") @@ -126,13 +124,13 @@ git-format-patch(1)." (concat mailscripts-extract-patches-branch-prefix branch) branch)))))) -(defun mailscripts--projectile-repo-and-branch (f &optional no-prefix) +(defun mailscripts--projectile-repo-and-branch (f) (let ((repo (projectile-completing-read "Select projectile project: " projectile-known-projects)) (branch (completing-read "Branch name (or leave blank to apply to current HEAD): " nil))) - (funcall f repo branch no-prefix))) + (funcall f repo branch))) (provide 'mailscripts) -- cgit v1.2.3 From 9c2a3cafdd25d19d94e53942cf170afd6af635d7 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Nov 2019 20:42:28 -0700 Subject: Revert "make it possible to suppress prefixing to the branch name" This reverts commit 3d33e7c0483bb9ab8de3ffd6a0372c8d2a0bffa0. Commit 7360648, which allows the user to suppress branch checkout, is a better way to let the user override their configured mailscripts-extract-patches-branch-prefix. Signed-off-by: Sean Whitton --- mailscripts.el | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index 43d06d0..1e8cf93 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -54,51 +54,45 @@ If NO-OPEN, don't open the thread." (notmuch-refresh-this-buffer))) ;;;###autoload -(defun notmuch-extract-thread-patches (repo branch &optional no-prefix) +(defun notmuch-extract-thread-patches (repo branch) "Extract patch series in current thread to branch BRANCH in repo REPO. -A prefix arg suppresses the effects of -`mailscripts-extract-patches-branch-prefix'. - The target branch may or may not already exist. See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): ") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) - (mailscripts--check-out-branch branch no-prefix) + (mailscripts--check-out-branch branch) (shell-command (format "notmuch-extract-patch %s | git am" (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) ;;;###autoload -(defun notmuch-extract-thread-patches-projectile (&optional no-prefix) +(defun notmuch-extract-thread-patches-projectile () "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." - (interactive "P") + (interactive) (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) ;;;###autoload -(defun notmuch-extract-message-patches (repo branch &optional no-prefix) +(defun notmuch-extract-message-patches (repo branch) "Extract patches attached to current message to branch BRANCH in repo REPO. -A prefix arg suppresses the effects of -`mailscripts-extract-patches-branch-prefix'. - The target branch may or may not already exist. Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): ") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) - (mailscripts--check-out-branch branch no-prefix) + (mailscripts--check-out-branch branch) (notmuch-foreach-mime-part (lambda (p) (let* ((disposition (mm-handle-disposition p)) @@ -110,17 +104,17 @@ git-format-patch(1)." mm-handle)))) ;;;###autoload -(defun notmuch-extract-message-patches-projectile (&optional no-prefix) +(defun notmuch-extract-message-patches-projectile () "Like `notmuch-extract-message-patches', but use projectile to choose the repo." - (interactive "P") + (interactive) (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) -(defun mailscripts--check-out-branch (branch no-prefix) +(defun mailscripts--check-out-branch (branch) (unless (string= branch "") (call-process-shell-command (format "git checkout -b %s" (shell-quote-argument - (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) + (if mailscripts-extract-patches-branch-prefix (concat mailscripts-extract-patches-branch-prefix branch) branch)))))) -- cgit v1.2.3 From 4c55ffc5e899e63603c09b0c37898243913e565c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 9 Nov 2019 15:01:43 -0700 Subject: changelog Signed-off-by: Sean Whitton --- debian/changelog | 6 ++++++ mailscripts.el | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index d5aa2a8..80a9232 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mailscripts (0.13-1) UNRELEASED; urgency=medium + + * notmuch-extract-patch: add -v/--reroll-count option + + -- Sean Whitton Sat, 09 Nov 2019 15:01:23 -0700 + mailscripts (0.12-1) unstable; urgency=medium * email-print-mime-structure: make typesafe. diff --git a/mailscripts.el b/mailscripts.el index 1e8cf93..ee05cd6 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,7 +1,7 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton -;; Version: 0.12 +;; Version: 0.13 ;; Package-Requires: (notmuch projectile) ;; Copyright (C) 2018, 2019 Sean Whitton -- cgit v1.2.3 From f06554efd870911a275b6e920afb133d0d61e68c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 9 Nov 2019 15:20:44 -0700 Subject: mailscripts.el: arg to pass --reroll-count to notmuch-extract-patch Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ mailscripts.el | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index 545e749..6787b43 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ mailscripts (0.13-1) UNRELEASED; urgency=medium * notmuch-extract-patch: add -v/--reroll-count option (Closes: #944418). + * mailscripts.el: prefix arg to pass -v/--reroll-count to + notmuch-extract-patch. -- Sean Whitton Sat, 09 Nov 2019 15:01:23 -0700 diff --git a/mailscripts.el b/mailscripts.el index ee05cd6..916aec8 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -54,21 +54,26 @@ If NO-OPEN, don't open the thread." (notmuch-refresh-this-buffer))) ;;;###autoload -(defun notmuch-extract-thread-patches (repo branch) +(defun notmuch-extract-thread-patches (repo branch &optional reroll-count) "Extract patch series in current thread to branch BRANCH in repo REPO. The target branch may or may not already exist. +With an optional prefix numeric argument REROLL-COUNT, try to +extract the nth revision of a series. See the --reroll-count +option detailed in notmuch-extract-patch(1). + See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): ") + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \np") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) (mailscripts--check-out-branch branch) (shell-command - (format "notmuch-extract-patch %s | git am" + (format "notmuch-extract-patch -v%d %s | git am" + (if reroll-count reroll-count 1) (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) @@ -76,7 +81,8 @@ threads to the notmuch-extract-patch(1) command." (defun notmuch-extract-thread-patches-projectile () "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." (interactive) - (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) + (mailscripts--projectile-repo-and-branch + 'notmuch-extract-thread-patches (prefix-numeric-value current-prefix-arg))) ;;;###autoload (defun notmuch-extract-message-patches (repo branch) @@ -118,13 +124,13 @@ git-format-patch(1)." (concat mailscripts-extract-patches-branch-prefix branch) branch)))))) -(defun mailscripts--projectile-repo-and-branch (f) +(defun mailscripts--projectile-repo-and-branch (f &rest args) (let ((repo (projectile-completing-read "Select projectile project: " projectile-known-projects)) (branch (completing-read "Branch name (or leave blank to apply to current HEAD): " nil))) - (funcall f repo branch))) + (apply f repo branch args))) (provide 'mailscripts) -- cgit v1.2.3