diff options
-rw-r--r-- | git-email.el | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/git-email.el b/git-email.el index 5fe7cfc..21a49a5 100644 --- a/git-email.el +++ b/git-email.el @@ -133,6 +133,14 @@ If the header is not found, return an empty string." (- (re-search-forward "\n\n") 1) (point-max)))) +(defun git-email--check-file (file) + "Check if FILE is a patch." + (if (and (file-readable-p file) + (or (string-match-p "\\.patch$" file) + (string-match-p "\\.diff$" file))) + file + (error "Not a valid patch!"))) + (defun git-email--dired-files () "Return list of filenames for marked files in `dired'. If no marks are found, return the filename at point." @@ -165,14 +173,16 @@ If no marks are found, return the filename at point." (defun git-email--get-filenames () "Return list of 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-files)) - ((eq major-mode 'vc-dir-mode) - (git-email--vc-dir-files)) - ((eq major-mode 'ibuffer-mode) - (git-email--ibuffer-files)) - (t - (git-email--minibuffer-file)))) + (let ((files (cond ((eq major-mode 'dired-mode) + (git-email--dired-files)) + ((eq major-mode 'vc-dir-mode) + (git-email--vc-dir-files)) + ((eq major-mode 'ibuffer-mode) + (git-email--ibuffer-files)) + (t + (git-email--minibuffer-file))))) + (when (mapcar 'git-email--check-file files) + files))) ;;;###autoload (defun git-email-apply-patch (project) |