From Linh Dang.
This commit is contained in:
Marius Vollmer 2008-08-19 23:43:34 +03:00
parent e110ed056a
commit e227560477
2 changed files with 64 additions and 4 deletions

View file

@ -1 +1,2 @@
Marius Vollmer <marius.vollmer@uni-dortmund.de>
Linh Dang <dang.linh@gmail.com>

View file

@ -1,6 +1,7 @@
;;; magit -- control Git from Emacs.
;; Copyright (C) 2008 Marius Vollmer
;; Copyright (C) 2008 Linh Dang
;;
;; Magit is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
@ -42,6 +43,59 @@
(require 'cl)
(require 'parse-time)
(defgroup magit nil
"Controlling Git from Emacs."
:prefix "magit-"
:group 'tools)
(defface magit-header-face
'((t))
"Face for generic header lines.
Many Magit faces inherit from this one by default."
:group 'magit)
(defface magit-section-title-face
'((t :weight bold :inherit magit-header-face))
"Face for section titles."
:group 'magit)
(defface magit-branch-face
'((t :weight bold :inherit magit-header-face))
"Face for the current branch."
:group 'magit)
(defface magit-diff-file-header-face
'((t :inherit magit-header-face))
"Face for diff file header lines."
:group 'magit)
(defface magit-diff-hunk-header-face
'((t :weight bold :inherit magit-header-face))
"Face for diff hunk header lines."
:group 'magit)
(defface magit-diff-add-face
'((((class color) (background light))
:foreground "blue1")
(((class color) (background dark))
:foreground "white"))
"Face for lines in a diff that have been added."
:group 'magit)
(defface magit-diff-none-face
'((t))
"Face for lines in a diff that are unchanged."
:group 'magit)
(defface magit-diff-del-face
'((((class color) (background light))
:foreground "red")
(((class color) (background dark))
:foreground "OrangeRed"))
"Face for lines in a diff that have been deleted."
:group 'magit)
;;; Utilities
(defun magit-goto-line (line)
@ -189,7 +243,7 @@
(defun magit-insert-section (section title washer cmd &rest args)
(let ((section-beg (point)))
(if title
(insert (propertize title 'face 'bold) "\n"))
(insert (propertize title 'face 'magit-section-title-face) "\n"))
(let* ((beg (point))
(status (apply 'call-process cmd nil t nil args))
(end (point)))
@ -442,6 +496,7 @@ Please see the manual for a complete description of Magit.
(let ((prefix (buffer-substring-no-properties
(point) (min (+ (point) n-files) (point-max)))))
(cond ((looking-at "^diff")
(magit-put-line-property 'face 'magit-diff-file-header-face)
(magit-wash-diff-propertize-diff head-seq head-beg head-end)
(magit-wash-diff-propertize-hunk head-seq hunk-seq
head-beg head-end hunk-beg)
@ -451,6 +506,7 @@ Please see the manual for a complete description of Magit.
(setq hunk-seq 0)
(setq hunk-beg nil))
((looking-at "^@+")
(magit-put-line-property 'face 'magit-diff-hunk-header-face)
(setq n-files (- (length (match-string 0)) 1))
(if (null head-end)
(setq head-end (point)))
@ -458,10 +514,12 @@ Please see the manual for a complete description of Magit.
head-beg head-end hunk-beg)
(setq hunk-seq (+ hunk-seq 1))
(setq hunk-beg (point)))
((looking-at "^ ")
(magit-put-line-property 'face 'magit-diff-none-face))
((string-match "\\+" prefix)
(magit-put-line-property 'face '(:foreground "blue1")))
(magit-put-line-property 'face 'magit-diff-add-face))
((string-match "-" prefix)
(magit-put-line-property 'face '(:foreground "red")))))
(magit-put-line-property 'face 'magit-diff-del-face))))
(forward-line)
(beginning-of-line))
(magit-wash-diff-propertize-diff head-seq head-beg head-end)
@ -480,7 +538,8 @@ Please see the manual for a complete description of Magit.
(insert (format "Remote: %s %s\n"
remote (magit-get "remote" remote "url"))))
(insert (format "Local: %s %s\n"
(propertize (or branch "(detached)") 'face 'bold)
(propertize (or branch "(detached)")
'face 'magit-branch-face)
(abbreviate-file-name default-directory)))
(insert
(format "Head: %s\n"