aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2009-09-20 19:51:35 +0000
committerDan Nicolaescu2009-09-20 19:51:35 +0000
commit0e172cc2c1a026d3a0afc58558cf177ee4687b25 (patch)
tree22f9e51fcf18e7a732b6e532def4a6aaeb9ece51
parent09c0132341493612361442371f4e1019883345c7 (diff)
downloademacs-0e172cc2c1a026d3a0afc58558cf177ee4687b25.tar.gz
emacs-0e172cc2c1a026d3a0afc58558cf177ee4687b25.zip
(vc-git-dir-extra-headers): Add keymap and mouse-face
properties to the stash strings. (vc-git-stash-list): Return a list of strings. (vc-git-stash-get-at-point, vc-git-stash-delete-at-point) (vc-git-stash-show-at-point): New functions. (vc-git-stash-map): New keymap.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/vc-git.el56
2 files changed, 54 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9efe3f36197..2cbd183b9a5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,13 @@
12009-09-20 Dan Nicolaescu <dann@ics.uci.edu> 12009-09-20 Dan Nicolaescu <dann@ics.uci.edu>
2 2
3 * register.el (ctl-x-r-map): Define the keys here instead of using autoload. 3 * vc-git.el (vc-git-dir-extra-headers): Add keymap and mouse-face
4 properties to the stash strings.
5 (vc-git-stash-list): Return a list of strings.
6 (vc-git-stash-get-at-point, vc-git-stash-delete-at-point)
7 (vc-git-stash-show-at-point): New functions.
8 (vc-git-stash-map): New keymap.
9
10 * register.el (ctl-x-r-map): Define the keys here instead of using autoload.
4 11
52009-09-20 Thierry Volpiatto <thierry.volpiatto@gmail.com> 122009-09-20 Thierry Volpiatto <thierry.volpiatto@gmail.com>
6 13
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 8d7b1e8bcc0..fe7b95cb43a 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -408,7 +408,6 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
408 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) 408 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
409 (progn 409 (progn
410 (setq branch (match-string 2 str)) 410 (setq branch (match-string 2 str))
411 (message "branch (%s)" branch)
412 (setq remote 411 (setq remote
413 (with-output-to-string 412 (with-output-to-string
414 (with-current-buffer standard-output 413 (with-current-buffer standard-output
@@ -424,7 +423,6 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
424 (setq remote-url (match-string 1 remote-url)))) 423 (setq remote-url (match-string 1 remote-url))))
425 "not (detached HEAD)") 424 "not (detached HEAD)")
426 ;; FIXME: maybe use a different face when nothing is stashed. 425 ;; FIXME: maybe use a different face when nothing is stashed.
427 (when (string= stash "") (setq stash "Nothing stashed"))
428 (concat 426 (concat
429 (propertize "Branch : " 'face 'font-lock-type-face) 427 (propertize "Branch : " 'face 'font-lock-type-face)
430 (propertize branch 428 (propertize branch
@@ -436,10 +434,20 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
436 (propertize remote-url 434 (propertize remote-url
437 'face 'font-lock-variable-name-face))) 435 'face 'font-lock-variable-name-face)))
438 "\n" 436 "\n"
439 (propertize "Stash : " 'face 'font-lock-type-face) 437 (if stash
440 (propertize 438 (concat
441 stash 439 (propertize "Stash :\n" 'face 'font-lock-type-face)
442 'face 'font-lock-variable-name-face)))) 440 (mapconcat
441 (lambda (x)
442 (propertize x
443 'face 'font-lock-variable-name-face
444 'mouse-face 'highlight
445 'keymap vc-git-stash-map))
446 stash "\n"))
447 (concat
448 (propertize "Stash : " 'face 'font-lock-type-face)
449 (propertize "Nothing stashed"
450 'face 'font-lock-variable-name-face))))))
443 451
444;;; STATE-CHANGING FUNCTIONS 452;;; STATE-CHANGING FUNCTIONS
445 453
@@ -797,10 +805,38 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
797 (pop-to-buffer (current-buffer))) 805 (pop-to-buffer (current-buffer)))
798 806
799(defun vc-git-stash-list () 807(defun vc-git-stash-list ()
800 (replace-regexp-in-string 808 (delete
801 "\n" "\n " 809 ""
802 (replace-regexp-in-string 810 (split-string
803 "^stash@" "" (vc-git--run-command-string nil "stash" "list")))) 811 (replace-regexp-in-string
812 "^stash@" " " (vc-git--run-command-string nil "stash" "list"))
813 "\n")))
814
815(defun vc-git-stash-get-at-point (point)
816 (save-excursion
817 (goto-char point)
818 (beginning-of-line)
819 (if (looking-at "^ +\\({[0-9]+}\\):")
820 (match-string 1)
821 (error "Cannot find stash at point"))))
822
823(defun vc-git-stash-delete-at-point ()
824 (interactive)
825 (let ((stash (vc-git-stash-get-at-point (point))))
826 (when (y-or-n-p (format "Remove stash %s ?" stash))
827 (vc-git--run-command-string nil "stash" "drop" (format "stash@%s" stash))
828 (vc-dir-refresh))))
829
830(defun vc-git-stash-show-at-point ()
831 (interactive)
832 (vc-git-stash-show (format "stash@%s" (vc-git-stash-get-at-point (point)))))
833
834(defvar vc-git-stash-map
835 (let ((map (make-sparse-keymap)))
836 (define-key map "\C-k" 'vc-git-stash-delete-at-point)
837 (define-key map "=" 'vc-git-stash-show-at-point)
838 (define-key map "\C-m" 'vc-git-stash-show-at-point)
839 map))
804 840
805 841
806;;; Internal commands 842;;; Internal commands