From 7220c43a4c082a38363181be365a1effecbab9ed Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 4 Aug 2008 03:26:34 +0300 Subject: [PATCH] (changes) --- git-status.el | 39 +++++++++++++++++++++++++++++++++++++-- test/BAR | 1 + 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/BAR diff --git a/git-status.el b/git-status.el index 61c73d7e..2a55811d 100644 --- a/git-status.el +++ b/git-status.el @@ -152,6 +152,7 @@ (define-key gits-keymap (kbd "S") 'git-stage-all) (define-key gits-keymap (kbd "a") 'gits-add-thing-at-point) (define-key gits-keymap (kbd "i") 'gits-ignore-thing-at-point) + (define-key gits-keymap (kbd "RET") 'gits-visit-thing-at-point) (define-key gits-keymap (kbd "c") 'git-commit) (define-key gits-keymap (kbd "p") 'gits-display-process)) @@ -167,6 +168,31 @@ (forward-line) (beginning-of-line))) +(defun gits-wash-diff (status) + (goto-char (point-min)) + (let ((n-files 1) + (hunk-beg nil) + (hunk-seq 0)) + (while (not (eobp)) + (let ((prefix (buffer-substring-no-properties + (point) (+ (point) n-files)))) + (cond ((looking-at "^@+") + (setq n-files (- (length (match-string 0)) 1)) + (if hunk-beg + (put-text-property hunk-beg (point) + 'gits-info (list 'hunk hunk-seq))) + (setq hunk-beg (point)) + (setq hunk-seq (+ hunk-seq 1))) + ((string-match "\\+" prefix) + (gits-put-line-property 'face '(:foreground "blue1"))) + ((string-match "-" prefix) + (gits-put-line-property 'face '(:foreground "red"))))) + (forward-line) + (beginning-of-line)) + (if hunk-beg + (put-text-property hunk-beg (point) + 'gits-info (list 'hunk hunk-seq))))) + (defun gits-update-status () (let ((buf (get-buffer "*git-status*"))) (save-excursion @@ -193,9 +219,9 @@ (insert "\n") (gits-insert-output "Untracked files:" 'gits-wash-other-files "git" "ls-files" "--others" "--exclude-standard") - (gits-insert-output "Local changes:" nil + (gits-insert-output "Local changes:" 'gits-wash-diff "git" "diff") - (gits-insert-output "Staged changes:" nil + (gits-insert-output "Staged changes:" 'gits-wash-diff "git" "diff" "--cached"))))) (defun git-status (dir) @@ -224,6 +250,15 @@ (append-to-file (concat (cadr info) "\n") nil ".gitignore") (gits-update-status)))))) +(defun gits-visit-thing-at-point () + (interactive) + (let ((info (get-char-property (point) 'gits-info))) + (message "visit %S" info) + (if info + (case (car info) + ((other-file) + (find-file (cadr info))))))) + ;;; Push and pull (defstruct gits-remote-info diff --git a/test/BAR b/test/BAR new file mode 100644 index 00000000..ed3193f8 --- /dev/null +++ b/test/BAR @@ -0,0 +1 @@ +Hi.