From: Charles A. Roelli Date: Wed, 21 Mar 2018 20:16:18 +0000 (+0100) Subject: Provide completion in vc-git-stash-* commands X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=91bdd5a4f087b6b264ba8e1bba8cd5b077df387b;p=emacs.git Provide completion in vc-git-stash-* commands * lisp/vc/vc-git.el (vc-git-stash-read-history) (vc-git-stash-read): New history variable and function. (vc-git-stash-show, vc-git-stash-apply, vc-git-stash-pop): Update their interactive specifications. --- diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 54564678153..bf1b0503422 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1481,9 +1481,24 @@ This command shares argument histories with \\[rgrep] and \\[grep]." (vc-git--call nil "stash" "save" name) (vc-resynch-buffer root t t)))) +(defvar vc-git-stash-read-history nil + "History for `vc-git-stash-read'.") + +(defun vc-git-stash-read (prompt) + "Read a Git stash. PROMPT is a string to prompt with." + (let ((stash (completing-read + prompt + (split-string + (or (vc-git--run-command-string nil "stash" "list") "") "\n") + nil :require-match nil 'vc-git-stash-read-history))) + (if (string-equal stash "") + (user-error "Not a stash") + (string-match "^stash@{[[:digit:]]+}" stash) + (match-string 0 stash)))) + (defun vc-git-stash-show (name) "Show the contents of stash NAME." - (interactive "sStash name: ") + (interactive (list (vc-git-stash-read "Show stash: "))) (vc-setup-buffer "*vc-git-stash*") (vc-git-command "*vc-git-stash*" 'async nil "stash" "show" "-p" name) (set-buffer "*vc-git-stash*") @@ -1493,13 +1508,13 @@ This command shares argument histories with \\[rgrep] and \\[grep]." (defun vc-git-stash-apply (name) "Apply stash NAME." - (interactive "sApply stash: ") + (interactive (list (vc-git-stash-read "Apply stash: "))) (vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" name) (vc-resynch-buffer (vc-git-root default-directory) t t)) (defun vc-git-stash-pop (name) "Pop stash NAME." - (interactive "sPop stash: ") + (interactive (list (vc-git-stash-read "Pop stash: "))) (vc-git-command "*vc-git-stash*" 0 nil "stash" "pop" "-q" name) (vc-resynch-buffer (vc-git-root default-directory) t t))