Cleanup diff washing propertizing.

This commit is contained in:
Marius Vollmer 2008-08-04 15:54:08 +03:00
parent 0a031d9f51
commit 84f8fbf028

View file

@ -167,17 +167,30 @@
(forward-line)
(beginning-of-line)))
(defun gits-propertize-hunk (beg end head-beg head-end)
(if beg
(put-text-property beg end
'gits-info (list 'hunk head-beg head-end beg end))))
(defun gits-wash-diff-propertize ()
;;; Ugh, dynamic scope. This uses HEAD-BEG, HEAD-END, HUNK-BEG, and
;;; HUNK-END.
(cond ((null head-end)
;; End of header
(setq head-end (point))
(if head-beg
(put-text-property head-beg head-end
'gits-info (list 'diff
head-beg head-end))))
(hunk-beg
;; End of hunk
(put-text-property hunk-beg hunk-end
'gits-info (list 'hunk
head-beg head-end
hunk-beg hunk-end)))))
(defun gits-wash-diff (status)
(goto-char (point-min))
(let ((n-files 1)
(head-beg nil)
(head-end nil)
(hunk-beg nil))
(hunk-beg nil)
(hunk-end nil))
(while (not (eobp))
(let ((prefix (buffer-substring-no-properties
(point) (+ (point) n-files))))
@ -186,14 +199,8 @@
(setq head-end nil))
((looking-at "^@+")
(setq n-files (- (length (match-string 0)) 1))
(cond ((null head-end)
(setq head-end (point))
(put-text-property head-beg head-end
'gits-info (list 'diff
head-beg head-end)))
(t
(gits-propertize-hunk hunk-beg (point)
head-beg head-end)))
(setq hunk-end (point))
(gits-wash-diff-propertize)
(setq hunk-beg (point)))
((string-match "\\+" prefix)
(gits-put-line-property 'face '(:foreground "blue1")))
@ -201,15 +208,7 @@
(gits-put-line-property 'face '(:foreground "red")))))
(forward-line)
(beginning-of-line))
(cond ((null head-end)
(setq head-end (point))
(if head-beg
(put-text-property head-beg head-end
'gits-info (list 'diff
head-beg head-end))))
(t
(gits-propertize-hunk hunk-beg (point)
head-beg head-end)))))
(gits-wash-diff-propertize)))
(defun gits-update-status ()
(let ((buf (get-buffer "*git-status*")))