diff options
-rw-r--r-- | git-email.el | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/git-email.el b/git-email.el index 92de56e..2a4addc 100644 --- a/git-email.el +++ b/git-email.el @@ -74,6 +74,13 @@ not set, the 'to' address will be empty." :type '(symbol) :group 'git-email) +(defcustom git-email-get-current-project-functions + '(git-email--get-current-project) + "Hooks to run to get the path to the current project. +The path should end with a trailing \"/\"." + :type 'hook + :group 'git-email) + (defcustom git-email-get-files-functions '(git-email--dired-files git-email--ibuffer-files @@ -122,6 +129,7 @@ If none of the functions return non-nil value, :type 'hook :group 'git-email) + ;;;; Remove Compiler warnings (declare-function dired-get-filename "dired.el") (declare-function dired-map-over-marks "dired.el") @@ -130,6 +138,7 @@ If none of the functions return non-nil value, (declare-function vc-dir-current-file "vc-dir.el") (declare-function log-view-current-entry "log-view.el") + ;;;; Get files to send (defun git-email--check-file (file) "Check if FILE is a patch." @@ -180,6 +189,18 @@ If no marks are found, return the filename at point." (when (mapcar #'git-email--check-file files) files))) +(defun git-email--get-current-project () + "Return the path of the current project. +Falls back to `default-directory'." + (let ((dir (or (and (bound-and-true-p projectile-known-projects) + (projectile-project-root)) + (and (bound-and-true-p project-list-file) + (cdr (project-current))) + (vc-root-dir) + (default-directory)))) + dir)) + + ;;;; Get contents from patch (defun git-email--extract-header (header) "Extract HEADER from current buffer." @@ -281,11 +302,13 @@ them into the message buffer." (re-search-backward "\\*\\*\\* SUBJECT HERE \\*\\*\\*" nil t)) (kill-line)))) + ;;;; Format patches (defun git-email--minibuffer-get-revision () "Let the user choose a git revision from the minibuffer." (interactive) - (let* ((default-directory (cdr (project-current))) + (let* ((default-directory (run-hook-with-args-until-success + 'git-email-get-current-project-functions)) ;; Last element is an empty string (revs (split-string (shell-command-to-string @@ -352,6 +375,7 @@ default behavior is to delete them after sending the message." (unless keep (mapc #'delete-file files)))) + ;;;; Operate on emails (defun git-email-send-all () "Send all unsent emails." |