diff options
Diffstat (limited to 'mailscripts.el')
-rw-r--r-- | mailscripts.el | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/mailscripts.el b/mailscripts.el index 50e3b89..8dc5875 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,8 +1,8 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton <spwhitton@spwhitton.name> -;; Version: 0.21 -;; Package-Requires: (notmuch projectile) +;; Version: 0.23 +;; Package-Requires: (notmuch) ;; Copyright (C) 2018, 2019, 2020 Sean Whitton @@ -21,8 +21,8 @@ ;;; Code: +(require 'cl-lib) (require 'notmuch) -(require 'projectile) (require 'thingatpt) (defgroup mailscripts nil @@ -46,6 +46,23 @@ Note that this does not prevent the creation of new branches." :type 'boolean :group 'mailscripts) +(defcustom mailscripts-project-library 'projectile + "Which project management library to use to choose from known projects. + +Some mailscripts functions allow selecting the repository to +which patches will be applied from the list of projects already +known to Emacs. There is more than one popular library for +maintaining a list of known projects, however, so this variable +must be set to the one you use. + +Once there is a more fully-featured version of project.el +included in the latest stable release of GNU Emacs, the default +value of this variable may change, so if you wish to continue +using Projectile, you should explicitly customize this." + :type '(choice (const :tag "project.el" project) + (const :tag "Projectile" projectile)) + :group 'mailscripts) + ;;;###autoload (defun notmuch-slurp-debbug (bug &optional no-open) "Slurp Debian bug with bug number BUG and open the thread in notmuch. @@ -123,10 +140,16 @@ threads to the notmuch-extract-patch(1) command." "*notmuch-apply-thread-series*"))) ;;;###autoload -(defun notmuch-extract-thread-patches-projectile () - "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." +(define-obsolete-function-alias + 'notmuch-extract-thread-patches-projectile + 'notmuch-extract-thread-patches-to-project + "mailscripts 0.22") + +;;;###autoload +(defun notmuch-extract-thread-patches-to-project () + "Like `notmuch-extract-thread-patches', but choose repo from known projects." (interactive) - (mailscripts--projectile-repo-and-branch + (mailscripts--project-repo-and-branch 'notmuch-extract-thread-patches (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) @@ -157,10 +180,16 @@ git-format-patch(1)." mm-handle)))) ;;;###autoload -(defun notmuch-extract-message-patches-projectile () - "Like `notmuch-extract-message-patches', but use projectile to choose the repo." +(define-obsolete-function-alias + 'notmuch-extract-message-patches-projectile + 'notmuch-extract-message-patches-to-project + "mailscripts 0.22") + +;;;###autoload +(defun notmuch-extract-message-patches-to-project () + "Like `notmuch-extract-message-patches', but choose repo from known projects." (interactive) - (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) + (mailscripts--project-repo-and-branch 'notmuch-extract-message-patches)) (defun mailscripts--check-out-branch (branch) (if (string= branch "") @@ -173,12 +202,20 @@ git-format-patch(1)." (concat mailscripts-extract-patches-branch-prefix branch) branch)))))) -(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))) +(defun mailscripts--project-repo-and-branch (f &rest args) + (let ((repo (cl-case mailscripts-project-library + ('project + (require 'project) + (project-prompt-project-dir)) + ('projectile + (require 'projectile) + (projectile-completing-read + "Select Projectile project: " projectile-known-projects)) + (nil + (user-error + "Please customize variable `mailscripts-project-library'.")))) + (branch (read-from-minibuffer + "Branch name (or leave blank to apply to current HEAD): "))) (apply f repo branch args))) (provide 'mailscripts) |