aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2012-05-25 03:55:40 +0300
committerJuri Linkov2012-05-25 03:55:40 +0300
commitbc1b21bb4e3594708570a1f503f69b8acc1e6814 (patch)
tree37a4e07a7c186ee88c3d86caa0c3ebdb4052bc66
parent532f361c96162f1a90756b2276f3091b1c273f23 (diff)
downloademacs-bc1b21bb4e3594708570a1f503f69b8acc1e6814.tar.gz
emacs-bc1b21bb4e3594708570a1f503f69b8acc1e6814.zip
Use the same diff color scheme as in modern VCSes (bug#10181).
* lisp/vc/diff-mode.el (diff-header, diff-file-header): Remove "green" to avoid confusion with `diff-added' that now uses green colors. (diff-removed): Use shades of red. (diff-added): Use shades of green. (diff-changed): Leave just the yellow color. (diff-use-changed-face): New variable. (diff-font-lock-keywords): Use `diff-use-changed-face' to decide how to highlight context diff changes. (diff-refine-change): Use shades of yellow. (diff-refine-removed): New face that uses shades of red. (diff-refine-added): New face that uses shades of green. (diff-refine-hunk): Use `diff-refine-change', `diff-refine-added', `diff-refine-removed' in the call to `smerge-refine-subst' depending on the value of `diff-use-changed-face'. * lisp/vc/ediff-init.el (ediff-current-diff-A, ediff-fine-diff-A): Add face condition `min-colors 88' with shades of red. (ediff-current-diff-B, ediff-fine-diff-B): Add face condition `min-colors 88' with shades of green. (ediff-current-diff-C, ediff-fine-diff-C): Add face condition `min-colors 88' with shades of yellow. * lisp/vc/smerge-mode.el (smerge-mine): Use shades of red. (smerge-other): Use shades of green. (smerge-base): Use shades of yellow. (smerge-refined-change): Empty face. (smerge-refined-removed): New face that uses shades of red. (smerge-refined-added): New face that uses shades of green. (smerge-refine-subst): Rename arg `props' to `props-c'. Add new args `props-r' and `props-a', and use them. Doc fix. (smerge-refine): Evaluate `smerge-use-changed-face' and depending on its value use different faces `smerge-refined-change', `smerge-refined-removed', `smerge-refined-added' in the call to `smerge-refine-subst'.
-rw-r--r--etc/NEWS11
-rw-r--r--lisp/ChangeLog39
-rw-r--r--lisp/vc/diff-mode.el107
-rw-r--r--lisp/vc/ediff-init.el36
-rw-r--r--lisp/vc/smerge-mode.el101
5 files changed, 236 insertions, 58 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f6a5bcda480..b097757dab6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -94,6 +94,17 @@ character when doing minibuffer filename prompts.
94 94
95* Changes in Specialized Modes and Packages in Emacs 24.2 95* Changes in Specialized Modes and Packages in Emacs 24.2
96 96
97** Diff mode
98
99Faces for changes now use the same diff color scheme as in modern VCSes
100where deletions are displayed in red (new faces `diff-refine-removed'
101and `smerge-refined-removed' and new definition of `diff-removed'),
102insertions in green (new faces `diff-refine-added' and
103`smerge-refined-added' and new definition of `diff-added').
104The variable `diff-use-changed-face' defines whether to use
105the face `diff-changed', or `diff-removed' and `diff-added'
106to highlight changes in context diffs.
107
97** `sh-script' 108** `sh-script'
98*** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair. 109*** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair.
99*** `sh-electric-here-document-mode' now controls auto-insertion of here-docs. 110*** `sh-electric-here-document-mode' now controls auto-insertion of here-docs.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index be684c559f9..4cd6f324956 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,42 @@
12012-05-25 Juri Linkov <juri@jurta.org>
2
3 Use the same diff color scheme as in modern VCSes (bug#10181).
4
5 * vc/diff-mode.el (diff-header, diff-file-header): Remove "green"
6 to avoid confusion with `diff-added' that now uses green colors.
7 (diff-removed): Use shades of red.
8 (diff-added): Use shades of green.
9 (diff-changed): Leave just the yellow color.
10 (diff-use-changed-face): New variable.
11 (diff-font-lock-keywords): Use `diff-use-changed-face' to decide
12 how to highlight context diff changes.
13 (diff-refine-change): Use shades of yellow.
14 (diff-refine-removed): New face that uses shades of red.
15 (diff-refine-added): New face that uses shades of green.
16 (diff-refine-hunk): Use `diff-refine-change', `diff-refine-added',
17 `diff-refine-removed' in the call to `smerge-refine-subst'
18 depending on the value of `diff-use-changed-face'.
19
20 * vc/smerge-mode.el (smerge-mine): Use shades of red.
21 (smerge-other): Use shades of green.
22 (smerge-base): Use shades of yellow.
23 (smerge-refined-change): Empty face.
24 (smerge-refined-removed): New face that uses shades of red.
25 (smerge-refined-added): New face that uses shades of green.
26 (smerge-refine-subst): Rename arg `props' to `props-c'. Add new
27 args `props-r' and `props-a', and use them. Doc fix.
28 (smerge-refine): Evaluate `smerge-use-changed-face' and depending
29 on its value use different faces `smerge-refined-change',
30 `smerge-refined-removed', `smerge-refined-added' in the call to
31 `smerge-refine-subst'.
32
33 * vc/ediff-init.el (ediff-current-diff-A, ediff-fine-diff-A):
34 Add face condition `min-colors 88' with shades of red.
35 (ediff-current-diff-B, ediff-fine-diff-B): Add face condition
36 `min-colors 88' with shades of green.
37 (ediff-current-diff-C, ediff-fine-diff-C): Add face condition
38 `min-colors 88' with shades of yellow.
39
12012-05-24 Glenn Morris <rgm@gnu.org> 402012-05-24 Glenn Morris <rgm@gnu.org>
2 41
3 * paths.el (prune-directory-list, remote-shell-program): Move to... 42 * paths.el (prune-directory-list, remote-shell-program): Move to...
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index f3f7d8ce61b..9034ffe520f 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -237,10 +237,8 @@ well."
237 :background "grey80") 237 :background "grey80")
238 (((class color) (min-colors 88) (background dark)) 238 (((class color) (min-colors 88) (background dark))
239 :background "grey45") 239 :background "grey45")
240 (((class color) (background light)) 240 (((class color))
241 :foreground "blue1" :weight bold) 241 :foreground "blue1" :weight bold)
242 (((class color) (background dark))
243 :foreground "green" :weight bold)
244 (t :weight bold)) 242 (t :weight bold))
245 "`diff-mode' face inherited by hunk and index header faces." 243 "`diff-mode' face inherited by hunk and index header faces."
246 :group 'diff-mode) 244 :group 'diff-mode)
@@ -252,9 +250,7 @@ well."
252 :background "grey70" :weight bold) 250 :background "grey70" :weight bold)
253 (((class color) (min-colors 88) (background dark)) 251 (((class color) (min-colors 88) (background dark))
254 :background "grey60" :weight bold) 252 :background "grey60" :weight bold)
255 (((class color) (background light)) 253 (((class color))
256 :foreground "green" :weight bold)
257 (((class color) (background dark))
258 :foreground "cyan" :weight bold) 254 :foreground "cyan" :weight bold)
259 (t :weight bold)) ; :height 1.3 255 (t :weight bold)) ; :height 1.3
260 "`diff-mode' face used to highlight file header lines." 256 "`diff-mode' face used to highlight file header lines."
@@ -277,14 +273,28 @@ well."
277(defvar diff-hunk-header-face 'diff-hunk-header) 273(defvar diff-hunk-header-face 'diff-hunk-header)
278 274
279(defface diff-removed 275(defface diff-removed
280 '((t :inherit diff-changed)) 276 '((default
277 :inherit diff-changed)
278 (((class color) (min-colors 88) (background light))
279 :background "#ffdddd")
280 (((class color) (min-colors 88) (background dark))
281 :background "#553333")
282 (((class color))
283 :foreground "red"))
281 "`diff-mode' face used to highlight removed lines." 284 "`diff-mode' face used to highlight removed lines."
282 :group 'diff-mode) 285 :group 'diff-mode)
283(define-obsolete-face-alias 'diff-removed-face 'diff-removed "22.1") 286(define-obsolete-face-alias 'diff-removed-face 'diff-removed "22.1")
284(defvar diff-removed-face 'diff-removed) 287(defvar diff-removed-face 'diff-removed)
285 288
286(defface diff-added 289(defface diff-added
287 '((t :inherit diff-changed)) 290 '((default
291 :inherit diff-changed)
292 (((class color) (min-colors 88) (background light))
293 :background "#ddffdd")
294 (((class color) (min-colors 88) (background dark))
295 :background "#335533")
296 (((class color))
297 :foreground "green"))
288 "`diff-mode' face used to highlight added lines." 298 "`diff-mode' face used to highlight added lines."
289 :group 'diff-mode) 299 :group 'diff-mode)
290(define-obsolete-face-alias 'diff-added-face 'diff-added "22.1") 300(define-obsolete-face-alias 'diff-added-face 'diff-added "22.1")
@@ -296,10 +306,8 @@ well."
296 '((((class color grayscale) (min-colors 88))) 306 '((((class color grayscale) (min-colors 88)))
297 ;; If the terminal lacks sufficient colors for shadowing, 307 ;; If the terminal lacks sufficient colors for shadowing,
298 ;; highlight changed lines explicitly. 308 ;; highlight changed lines explicitly.
299 (((class color) (background light)) 309 (((class color))
300 :foreground "magenta" :weight bold :slant italic) 310 :foreground "yellow"))
301 (((class color) (background dark))
302 :foreground "yellow" :weight bold :slant italic))
303 "`diff-mode' face used to highlight changed lines." 311 "`diff-mode' face used to highlight changed lines."
304 :group 'diff-mode) 312 :group 'diff-mode)
305(define-obsolete-face-alias 'diff-changed-face 'diff-changed "22.1") 313(define-obsolete-face-alias 'diff-changed-face 'diff-changed "22.1")
@@ -374,6 +382,13 @@ well."
374(defconst diff-context-mid-hunk-header-re 382(defconst diff-context-mid-hunk-header-re
375 "--- \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? ----$") 383 "--- \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? ----$")
376 384
385(defvar diff-use-changed-face (and (face-differs-from-default-p diff-changed-face)
386 (not (face-equal diff-changed-face diff-added-face))
387 (not (face-equal diff-changed-face diff-removed-face)))
388 "If non-nil, use the face `diff-changed' for changed lines in context diffs.
389Otherwise, use the face `diff-removed' for removed lines,
390and the face `diff-added' for added lines.")
391
377(defvar diff-font-lock-keywords 392(defvar diff-font-lock-keywords
378 `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$") 393 `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$")
379 (1 diff-hunk-header-face) (6 diff-function-face)) 394 (1 diff-hunk-header-face) (6 diff-function-face))
@@ -393,8 +408,25 @@ well."
393 ("^\\([+>]\\)\\(.*\n\\)" 408 ("^\\([+>]\\)\\(.*\n\\)"
394 (1 diff-indicator-added-face) (2 diff-added-face)) 409 (1 diff-indicator-added-face) (2 diff-added-face))
395 ("^\\(!\\)\\(.*\n\\)" 410 ("^\\(!\\)\\(.*\n\\)"
396 (1 diff-indicator-changed-face) (2 diff-changed-face)) 411 (1 (if diff-use-changed-face
397 ("^Index: \\(.+\\).*\n" 412 diff-indicator-changed-face
413 ;; Otherwise, search for `diff-context-mid-hunk-header-re' and
414 ;; if the line of context diff is above, use `diff-removed-face';
415 ;; if below, use `diff-added-face'.
416 (save-match-data
417 (let ((limit (save-excursion (diff-beginning-of-hunk))))
418 (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
419 diff-indicator-added-face
420 diff-indicator-removed-face)))))
421 (2 (if diff-use-changed-face
422 diff-changed-face
423 ;; Otherwise, use the same method as above.
424 (save-match-data
425 (let ((limit (save-excursion (diff-beginning-of-hunk))))
426 (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
427 diff-added-face
428 diff-removed-face))))))
429 ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
398 (0 diff-header-face) (1 diff-index-face prepend)) 430 (0 diff-header-face) (1 diff-index-face prepend))
399 ("^Only in .*\n" . diff-nonexistent-face) 431 ("^Only in .*\n" . diff-nonexistent-face)
400 ("^\\(#\\)\\(.*\\)" 432 ("^\\(#\\)\\(.*\\)"
@@ -1847,17 +1879,35 @@ For use in `add-log-current-defun-function'."
1847 1879
1848(defface diff-refine-change 1880(defface diff-refine-change
1849 '((((class color) (min-colors 88) (background light)) 1881 '((((class color) (min-colors 88) (background light))
1850 :background "grey85") 1882 :background "#ffff55")
1851 (((class color) (min-colors 88) (background dark)) 1883 (((class color) (min-colors 88) (background dark))
1852 :background "grey60") 1884 :background "#aaaa22")
1853 (((class color) (background light)) 1885 (t :inverse-video t))
1854 :background "yellow")
1855 (((class color) (background dark))
1856 :background "green")
1857 (t :weight bold))
1858 "Face used for char-based changes shown by `diff-refine-hunk'." 1886 "Face used for char-based changes shown by `diff-refine-hunk'."
1859 :group 'diff-mode) 1887 :group 'diff-mode)
1860 1888
1889(defface diff-refine-removed
1890 '((default
1891 :inherit diff-refine-change)
1892 (((class color) (min-colors 88) (background light))
1893 :background "#ffaaaa")
1894 (((class color) (min-colors 88) (background dark))
1895 :background "#aa2222"))
1896 "Face used for removed characters shown by `diff-refine-hunk'."
1897 :group 'diff-mode
1898 :version "24.2")
1899
1900(defface diff-refine-added
1901 '((default
1902 :inherit diff-refine-change)
1903 (((class color) (min-colors 88) (background light))
1904 :background "#aaffaa")
1905 (((class color) (min-colors 88) (background dark))
1906 :background "#22aa22"))
1907 "Face used for added characters shown by `diff-refine-hunk'."
1908 :group 'diff-mode
1909 :version "24.2")
1910
1861(defun diff-refine-preproc () 1911(defun diff-refine-preproc ()
1862 (while (re-search-forward "^[+>]" nil t) 1912 (while (re-search-forward "^[+>]" nil t)
1863 ;; Remove spurious changes due to the fact that one side of the hunk is 1913 ;; Remove spurious changes due to the fact that one side of the hunk is
@@ -1871,7 +1921,7 @@ For use in `add-log-current-defun-function'."
1871 ) 1921 )
1872 1922
1873(declare-function smerge-refine-subst "smerge-mode" 1923(declare-function smerge-refine-subst "smerge-mode"
1874 (beg1 end1 beg2 end2 props &optional preproc)) 1924 (beg1 end1 beg2 end2 props-c &optional preproc props-r props-a))
1875 1925
1876(defun diff-refine-hunk () 1926(defun diff-refine-hunk ()
1877 "Highlight changes of hunk at point at a finer granularity." 1927 "Highlight changes of hunk at point at a finer granularity."
@@ -1882,7 +1932,9 @@ For use in `add-log-current-defun-function'."
1882 (let* ((start (point)) 1932 (let* ((start (point))
1883 (style (diff-hunk-style)) ;Skips the hunk header as well. 1933 (style (diff-hunk-style)) ;Skips the hunk header as well.
1884 (beg (point)) 1934 (beg (point))
1885 (props '((diff-mode . fine) (face diff-refine-change))) 1935 (props-c '((diff-mode . fine) (face diff-refine-change)))
1936 (props-r '((diff-mode . fine) (face diff-refine-removed)))
1937 (props-a '((diff-mode . fine) (face diff-refine-added)))
1886 ;; Be careful to go back to `start' so diff-end-of-hunk gets 1938 ;; Be careful to go back to `start' so diff-end-of-hunk gets
1887 ;; to read the hunk header's line info. 1939 ;; to read the hunk header's line info.
1888 (end (progn (goto-char start) (diff-end-of-hunk) (point)))) 1940 (end (progn (goto-char start) (diff-end-of-hunk) (point))))
@@ -1896,7 +1948,7 @@ For use in `add-log-current-defun-function'."
1896 end t) 1948 end t)
1897 (smerge-refine-subst (match-beginning 0) (match-end 1) 1949 (smerge-refine-subst (match-beginning 0) (match-end 1)
1898 (match-end 1) (match-end 0) 1950 (match-end 1) (match-end 0)
1899 props 'diff-refine-preproc))) 1951 nil 'diff-refine-preproc props-r props-a)))
1900 (context 1952 (context
1901 (let* ((middle (save-excursion (re-search-forward "^---"))) 1953 (let* ((middle (save-excursion (re-search-forward "^---")))
1902 (other middle)) 1954 (other middle))
@@ -1908,14 +1960,17 @@ For use in `add-log-current-defun-function'."
1908 (setq other (match-end 0)) 1960 (setq other (match-end 0))
1909 (match-beginning 0)) 1961 (match-beginning 0))
1910 other 1962 other
1911 props 'diff-refine-preproc)))) 1963 (if diff-use-changed-face props-c)
1964 'diff-refine-preproc
1965 (unless diff-use-changed-face props-r)
1966 (unless diff-use-changed-face props-a)))))
1912 (t ;; Normal diffs. 1967 (t ;; Normal diffs.
1913 (let ((beg1 (1+ (point)))) 1968 (let ((beg1 (1+ (point))))
1914 (when (re-search-forward "^---.*\n" end t) 1969 (when (re-search-forward "^---.*\n" end t)
1915 ;; It's a combined add&remove, so there's something to do. 1970 ;; It's a combined add&remove, so there's something to do.
1916 (smerge-refine-subst beg1 (match-beginning 0) 1971 (smerge-refine-subst beg1 (match-beginning 0)
1917 (match-end 0) end 1972 (match-end 0) end
1918 props 'diff-refine-preproc)))))))) 1973 nil 'diff-refine-preproc props-r props-a))))))))
1919 1974
1920(defun diff-undo (&optional arg) 1975(defun diff-undo (&optional arg)
1921 "Perform `undo', ignoring the buffer's read-only status." 1976 "Perform `undo', ignoring the buffer's read-only status."
diff --git a/lisp/vc/ediff-init.el b/lisp/vc/ediff-init.el
index 80ed9356850..674688df1c2 100644
--- a/lisp/vc/ediff-init.el
+++ b/lisp/vc/ediff-init.el
@@ -853,7 +853,11 @@ TYPE-OF-EMACS is either 'xemacs or 'emacs."
853 853
854(defface ediff-current-diff-A 854(defface ediff-current-diff-A
855 (if (featurep 'emacs) 855 (if (featurep 'emacs)
856 '((((class color) (min-colors 16)) 856 '((((class color) (min-colors 88) (background light))
857 :background "#ffdddd")
858 (((class color) (min-colors 88) (background dark))
859 :background "#553333")
860 (((class color) (min-colors 16))
857 (:foreground "firebrick" :background "pale green")) 861 (:foreground "firebrick" :background "pale green"))
858 (((class color)) 862 (((class color))
859 (:foreground "blue3" :background "yellow3")) 863 (:foreground "blue3" :background "yellow3"))
@@ -882,7 +886,11 @@ this variable represents.")
882 886
883(defface ediff-current-diff-B 887(defface ediff-current-diff-B
884 (if (featurep 'emacs) 888 (if (featurep 'emacs)
885 '((((class color) (min-colors 16)) 889 '((((class color) (min-colors 88) (background light))
890 :background "#ddffdd")
891 (((class color) (min-colors 88) (background dark))
892 :background "#335533")
893 (((class color) (min-colors 16))
886 (:foreground "DarkOrchid" :background "Yellow")) 894 (:foreground "DarkOrchid" :background "Yellow"))
887 (((class color)) 895 (((class color))
888 (:foreground "magenta3" :background "yellow3" 896 (:foreground "magenta3" :background "yellow3"
@@ -912,7 +920,11 @@ this variable represents.")
912 920
913(defface ediff-current-diff-C 921(defface ediff-current-diff-C
914 (if (featurep 'emacs) 922 (if (featurep 'emacs)
915 '((((class color) (min-colors 16)) 923 '((((class color) (min-colors 88) (background light))
924 :background "#ffffaa")
925 (((class color) (min-colors 88) (background dark))
926 :background "#888833")
927 (((class color) (min-colors 16))
916 (:foreground "Navy" :background "Pink")) 928 (:foreground "Navy" :background "Pink"))
917 (((class color)) 929 (((class color))
918 (:foreground "cyan3" :background "yellow3" :weight bold)) 930 (:foreground "cyan3" :background "yellow3" :weight bold))
@@ -968,7 +980,11 @@ this variable represents.")
968 980
969(defface ediff-fine-diff-A 981(defface ediff-fine-diff-A
970 (if (featurep 'emacs) 982 (if (featurep 'emacs)
971 '((((class color) (min-colors 16)) 983 '((((class color) (min-colors 88) (background light))
984 :background "#ffaaaa")
985 (((class color) (min-colors 88) (background dark))
986 :background "#aa2222")
987 (((class color) (min-colors 16))
972 (:foreground "Navy" :background "sky blue")) 988 (:foreground "Navy" :background "sky blue"))
973 (((class color)) 989 (((class color))
974 (:foreground "white" :background "sky blue" :weight bold)) 990 (:foreground "white" :background "sky blue" :weight bold))
@@ -989,7 +1005,11 @@ this variable represents.")
989 1005
990(defface ediff-fine-diff-B 1006(defface ediff-fine-diff-B
991 (if (featurep 'emacs) 1007 (if (featurep 'emacs)
992 '((((class color) (min-colors 16)) 1008 '((((class color) (min-colors 88) (background light))
1009 :background "#aaffaa")
1010 (((class color) (min-colors 88) (background dark))
1011 :background "#22aa22")
1012 (((class color) (min-colors 16))
993 (:foreground "Black" :background "cyan")) 1013 (:foreground "Black" :background "cyan"))
994 (((class color)) 1014 (((class color))
995 (:foreground "magenta3" :background "cyan3")) 1015 (:foreground "magenta3" :background "cyan3"))
@@ -1010,7 +1030,11 @@ this variable represents.")
1010 1030
1011(defface ediff-fine-diff-C 1031(defface ediff-fine-diff-C
1012 (if (featurep 'emacs) 1032 (if (featurep 'emacs)
1013 '((((type pc)) 1033 '((((class color) (min-colors 88) (background light))
1034 :background "#ffff55")
1035 (((class color) (min-colors 88) (background dark))
1036 :background "#aaaa22")
1037 (((type pc))
1014 (:foreground "white" :background "Turquoise")) 1038 (:foreground "white" :background "Turquoise"))
1015 (((class color) (min-colors 16)) 1039 (((class color) (min-colors 16))
1016 (:foreground "Black" :background "Turquoise")) 1040 (:foreground "Black" :background "Turquoise"))
diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index 3db1f669d63..cf1cdabc80f 100644
--- a/lisp/vc/smerge-mode.el
+++ b/lisp/vc/smerge-mode.el
@@ -78,36 +78,36 @@ Used in `smerge-diff-base-mine' and related functions."
78 :type 'boolean) 78 :type 'boolean)
79 79
80(defface smerge-mine 80(defface smerge-mine
81 '((((min-colors 88) (background light)) 81 '((((class color) (min-colors 88) (background light))
82 (:foreground "blue1")) 82 :background "#ffdddd")
83 (((background light)) 83 (((class color) (min-colors 88) (background dark))
84 (:foreground "blue")) 84 :background "#553333")
85 (((min-colors 88) (background dark)) 85 (((class color))
86 (:foreground "cyan1")) 86 :foreground "red"))
87 (((background dark))
88 (:foreground "cyan")))
89 "Face for your code." 87 "Face for your code."
90 :group 'smerge) 88 :group 'smerge)
91(define-obsolete-face-alias 'smerge-mine-face 'smerge-mine "22.1") 89(define-obsolete-face-alias 'smerge-mine-face 'smerge-mine "22.1")
92(defvar smerge-mine-face 'smerge-mine) 90(defvar smerge-mine-face 'smerge-mine)
93 91
94(defface smerge-other 92(defface smerge-other
95 '((((background light)) 93 '((((class color) (min-colors 88) (background light))
96 (:foreground "darkgreen")) 94 :background "#ddffdd")
97 (((background dark)) 95 (((class color) (min-colors 88) (background dark))
98 (:foreground "lightgreen"))) 96 :background "#335533")
97 (((class color))
98 :foreground "green"))
99 "Face for the other code." 99 "Face for the other code."
100 :group 'smerge) 100 :group 'smerge)
101(define-obsolete-face-alias 'smerge-other-face 'smerge-other "22.1") 101(define-obsolete-face-alias 'smerge-other-face 'smerge-other "22.1")
102(defvar smerge-other-face 'smerge-other) 102(defvar smerge-other-face 'smerge-other)
103 103
104(defface smerge-base 104(defface smerge-base
105 '((((min-colors 88) (background light)) 105 '((((class color) (min-colors 88) (background light))
106 (:foreground "red1")) 106 :background "#ffffaa")
107 (((background light)) 107 (((class color) (min-colors 88) (background dark))
108 (:foreground "red")) 108 :background "#888833")
109 (((background dark)) 109 (((class color))
110 (:foreground "orange"))) 110 :foreground "yellow"))
111 "Face for the base code." 111 "Face for the base code."
112 :group 'smerge) 112 :group 'smerge)
113(define-obsolete-face-alias 'smerge-base-face 'smerge-base "22.1") 113(define-obsolete-face-alias 'smerge-base-face 'smerge-base "22.1")
@@ -124,10 +124,34 @@ Used in `smerge-diff-base-mine' and related functions."
124(defvar smerge-markers-face 'smerge-markers) 124(defvar smerge-markers-face 'smerge-markers)
125 125
126(defface smerge-refined-change 126(defface smerge-refined-change
127 '((t :background "yellow")) 127 '((t nil))
128 "Face used for char-based changes shown by `smerge-refine'." 128 "Face used for char-based changes shown by `smerge-refine'."
129 :group 'smerge) 129 :group 'smerge)
130 130
131(defface smerge-refined-removed
132 '((default
133 :inherit smerge-refined-change)
134 (((class color) (min-colors 88) (background light))
135 :background "#ffaaaa")
136 (((class color) (min-colors 88) (background dark))
137 :background "#aa2222")
138 (t :inverse-video t))
139 "Face used for removed characters shown by `smerge-refine'."
140 :group 'smerge
141 :version "24.2")
142
143(defface smerge-refined-added
144 '((default
145 :inherit smerge-refined-change)
146 (((class color) (min-colors 88) (background light))
147 :background "#aaffaa")
148 (((class color) (min-colors 88) (background dark))
149 :background "#22aa22")
150 (t :inverse-video t))
151 "Face used for added characters shown by `smerge-refine'."
152 :group 'smerge
153 :version "24.2")
154
131(easy-mmode-defmap smerge-basic-map 155(easy-mmode-defmap smerge-basic-map
132 `(("n" . smerge-next) 156 `(("n" . smerge-next)
133 ("p" . smerge-prev) 157 ("p" . smerge-prev)
@@ -980,9 +1004,17 @@ chars to try and eliminate some spurious differences."
980 (dolist (x props) (overlay-put ol (car x) (cdr x))) 1004 (dolist (x props) (overlay-put ol (car x) (cdr x)))
981 ol))))) 1005 ol)))))
982 1006
983(defun smerge-refine-subst (beg1 end1 beg2 end2 props &optional preproc) 1007(defun smerge-refine-subst (beg1 end1 beg2 end2 props-c &optional preproc props-r props-a)
984 "Show fine differences in the two regions BEG1..END1 and BEG2..END2. 1008 "Show fine differences in the two regions BEG1..END1 and BEG2..END2.
985PROPS is an alist of properties to put (via overlays) on the changes. 1009PROPS-C is an alist of properties to put (via overlays) on the changes.
1010PROPS-R is an alist of properties to put on removed characters.
1011PROPS-A is an alist of properties to put on added characters.
1012If PROPS-R and PROPS-A are nil, put PROPS-C on all changes.
1013If PROPS-C is nil, but PROPS-R and PROPS-A are non-nil,
1014put PROPS-A on added characters, PROPS-R on removed characters.
1015If PROPS-C, PROPS-R and PROPS-A are non-nil, put PROPS-C on changed characters,
1016PROPS-A on added characters, and PROPS-R on removed characters.
1017
986If non-nil, PREPROC is called with no argument in a buffer that contains 1018If non-nil, PREPROC is called with no argument in a buffer that contains
987a copy of a region, just before preparing it to for `diff'. It can be 1019a copy of a region, just before preparing it to for `diff'. It can be
988used to replace chars to try and eliminate some spurious differences." 1020used to replace chars to try and eliminate some spurious differences."
@@ -1026,10 +1058,18 @@ used to replace chars to try and eliminate some spurious differences."
1026 (m5 (match-string 5))) 1058 (m5 (match-string 5)))
1027 (when (memq op '(?d ?c)) 1059 (when (memq op '(?d ?c))
1028 (setq last1 1060 (setq last1
1029 (smerge-refine-highlight-change buf beg1 m1 m2 props))) 1061 (smerge-refine-highlight-change
1062 buf beg1 m1 m2
1063 ;; Try to use props-c only for changed chars,
1064 ;; fallback to props-r for changed/removed chars,
1065 ;; but if props-r is nil then fallback to props-c.
1066 (or (and (eq op '?c) props-c) props-r props-c))))
1030 (when (memq op '(?a ?c)) 1067 (when (memq op '(?a ?c))
1031 (setq last2 1068 (setq last2
1032 (smerge-refine-highlight-change buf beg2 m4 m5 props)))) 1069 (smerge-refine-highlight-change
1070 buf beg2 m4 m5
1071 ;; Same logic as for removed chars above.
1072 (or (and (eq op '?c) props-c) props-a props-c)))))
1033 (forward-line 1) ;Skip hunk header. 1073 (forward-line 1) ;Skip hunk header.
1034 (and (re-search-forward "^[0-9]" nil 'move) ;Skip hunk body. 1074 (and (re-search-forward "^[0-9]" nil 'move) ;Skip hunk body.
1035 (goto-char (match-beginning 0)))) 1075 (goto-char (match-beginning 0))))
@@ -1081,7 +1121,11 @@ repeating the command will highlight other two parts."
1081 ((eq (match-end 3) (match-beginning 3)) 3) 1121 ((eq (match-end 3) (match-beginning 3)) 3)
1082 (t 2))) 1122 (t 2)))
1083 (let ((n1 (if (eq part 1) 2 1)) 1123 (let ((n1 (if (eq part 1) 2 1))
1084 (n2 (if (eq part 3) 2 3))) 1124 (n2 (if (eq part 3) 2 3))
1125 (smerge-use-changed-face
1126 (and (face-differs-from-default-p 'smerge-refined-change)
1127 (not (face-equal 'smerge-refined-change 'smerge-refined-added))
1128 (not (face-equal 'smerge-refined-change 'smerge-refined-removed)))))
1085 (smerge-ensure-match n1) 1129 (smerge-ensure-match n1)
1086 (smerge-ensure-match n2) 1130 (smerge-ensure-match n2)
1087 (with-silent-modifications 1131 (with-silent-modifications
@@ -1090,8 +1134,13 @@ repeating the command will highlight other two parts."
1090 (cons (buffer-chars-modified-tick) part))) 1134 (cons (buffer-chars-modified-tick) part)))
1091 (smerge-refine-subst (match-beginning n1) (match-end n1) 1135 (smerge-refine-subst (match-beginning n1) (match-end n1)
1092 (match-beginning n2) (match-end n2) 1136 (match-beginning n2) (match-end n2)
1093 '((smerge . refine) 1137 (if smerge-use-changed-face
1094 (face . smerge-refined-change))))) 1138 '((smerge . refine) (face . smerge-refined-change)))
1139 nil
1140 (unless smerge-use-changed-face
1141 '((smerge . refine) (face . smerge-refined-removed)))
1142 (unless smerge-use-changed-face
1143 '((smerge . refine) (face . smerge-refined-added))))))
1095 1144
1096(defun smerge-diff (n1 n2) 1145(defun smerge-diff (n1 n2)
1097 (smerge-match-conflict) 1146 (smerge-match-conflict)