+(defface stgit-description-face
+ '((((background dark)) (:foreground "tan"))
+ (((background light)) (:foreground "dark red")))
+ "The face used for StGit desriptions")
+
+(defface stgit-top-patch-face
+ '((((background dark)) (:weight bold :foreground "yellow"))
+ (((background light)) (:weight bold :foreground "purple"))
+ (t (:weight bold)))
+ "The face used for the top patch names")
+
+(defface stgit-applied-patch-face
+ '((((background dark)) (:foreground "light yellow"))
+ (((background light)) (:foreground "purple"))
+ (t ()))
+ "The face used for applied patch names")
+
+(defface stgit-unapplied-patch-face
+ '((((background dark)) (:foreground "gray80"))
+ (((background light)) (:foreground "orchid"))
+ (t ()))
+ "The face used for unapplied patch names")
+
+(defun stgit-rescan ()
+ "Rescan the status buffer."
+ (save-excursion
+ (let ((marked ()))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (cond ((looking-at "Branch: \\(.*\\)")
+ (put-text-property (match-beginning 1) (match-end 1)
+ 'face 'bold))
+ ((looking-at "\\([>+-]\\)\\( \\)\\([^ ]+\\) *[|#] \\(.*\\)")
+ (let ((state (match-string 1))
+ (patchsym (intern (match-string 3))))
+ (put-text-property
+ (match-beginning 3) (match-end 3) 'face
+ (cond ((string= state ">") 'stgit-top-patch-face)
+ ((string= state "+") 'stgit-applied-patch-face)
+ ((string= state "-") 'stgit-unapplied-patch-face)))
+ (put-text-property (match-beginning 4) (match-end 4)
+ 'face 'stgit-description-face)
+ (when (memq patchsym stgit-marked-patches)
+ (replace-match "*" nil nil nil 2)
+ (setq marked (cons patchsym marked)))))
+ ((or (looking-at "stg series: Branch \".*\" not initialised")
+ (looking-at "stg series: .*: branch not initialized"))
+ (forward-line 1)
+ (insert "Run M-x stgit-init to initialise")))
+ (forward-line 1))
+ (setq stgit-marked-patches (nreverse marked)))))
+
+(defun stgit-quit ()
+ "Hide the stgit buffer"
+ (interactive)
+ (bury-buffer))
+