aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles A. Roelli2018-03-21 21:16:18 +0100
committerCharles A. Roelli2018-03-21 21:16:18 +0100
commit61dfc2c283f83f17bd9c757d5b953099d09e8f8c (patch)
tree200f97b08c02ec175359c5608ece4d783e8cb6aa
parente70d0c9e66d7a8609450b2889869d16aeb0363b5 (diff)
downloademacs-61dfc2c283f83f17bd9c757d5b953099d09e8f8c.tar.gz
emacs-61dfc2c283f83f17bd9c757d5b953099d09e8f8c.zip
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.
-rw-r--r--lisp/vc/vc-git.el21
1 files changed, 18 insertions, 3 deletions
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]."
1481 (vc-git--call nil "stash" "save" name) 1481 (vc-git--call nil "stash" "save" name)
1482 (vc-resynch-buffer root t t)))) 1482 (vc-resynch-buffer root t t))))
1483 1483
1484(defvar vc-git-stash-read-history nil
1485 "History for `vc-git-stash-read'.")
1486
1487(defun vc-git-stash-read (prompt)
1488 "Read a Git stash. PROMPT is a string to prompt with."
1489 (let ((stash (completing-read
1490 prompt
1491 (split-string
1492 (or (vc-git--run-command-string nil "stash" "list") "") "\n")
1493 nil :require-match nil 'vc-git-stash-read-history)))
1494 (if (string-equal stash "")
1495 (user-error "Not a stash")
1496 (string-match "^stash@{[[:digit:]]+}" stash)
1497 (match-string 0 stash))))
1498
1484(defun vc-git-stash-show (name) 1499(defun vc-git-stash-show (name)
1485 "Show the contents of stash NAME." 1500 "Show the contents of stash NAME."
1486 (interactive "sStash name: ") 1501 (interactive (list (vc-git-stash-read "Show stash: ")))
1487 (vc-setup-buffer "*vc-git-stash*") 1502 (vc-setup-buffer "*vc-git-stash*")
1488 (vc-git-command "*vc-git-stash*" 'async nil "stash" "show" "-p" name) 1503 (vc-git-command "*vc-git-stash*" 'async nil "stash" "show" "-p" name)
1489 (set-buffer "*vc-git-stash*") 1504 (set-buffer "*vc-git-stash*")
@@ -1493,13 +1508,13 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
1493 1508
1494(defun vc-git-stash-apply (name) 1509(defun vc-git-stash-apply (name)
1495 "Apply stash NAME." 1510 "Apply stash NAME."
1496 (interactive "sApply stash: ") 1511 (interactive (list (vc-git-stash-read "Apply stash: ")))
1497 (vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" name) 1512 (vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" name)
1498 (vc-resynch-buffer (vc-git-root default-directory) t t)) 1513 (vc-resynch-buffer (vc-git-root default-directory) t t))
1499 1514
1500(defun vc-git-stash-pop (name) 1515(defun vc-git-stash-pop (name)
1501 "Pop stash NAME." 1516 "Pop stash NAME."
1502 (interactive "sPop stash: ") 1517 (interactive (list (vc-git-stash-read "Pop stash: ")))
1503 (vc-git-command "*vc-git-stash*" 0 nil "stash" "pop" "-q" name) 1518 (vc-git-command "*vc-git-stash*" 0 nil "stash" "pop" "-q" name)
1504 (vc-resynch-buffer (vc-git-root default-directory) t t)) 1519 (vc-resynch-buffer (vc-git-root default-directory) t t))
1505 1520