emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Diff faces


From: Juri Linkov
Subject: Re: Diff faces
Date: Mon, 15 Oct 2007 00:30:29 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

>> Wouldn't it be better to use the same colors for equivalent faces of
>> ediff, smerge and diff-mode?  So that ediff-fine-diff-B, diff-fine-change
>> and smerge-refined-change will be the same and so on.
>
> Could be.  My use of faces (i.e. "mostly no colors, only font/size/darkness
> changes") is rather atypical and I simply cannot imagine how people live
> with the default angry fruit-salad, so I prefer to let other people deal
> with it.

I like the current shadows-of-gray color scheme used in diff-mode.
And even ediff uses similar gray colors to highlight inactive hunks.
The only complaint I currently have is that the yellow color of the new
face `diff-fine-change' doesn't fit into this scheme.  What do you think
about changing it to a shadow of gray?  Alternatively, you could use
fruit-salad colors only for the refined hunk in diff-mode (similar to the
colors of the active hunk in ediff).

BTW, I think the current character-wise refinement in diff-mode and in
smerge-mode is not very useful.  More useful would be to refine it on the
word or symbol basis.  I have an experimental patch that produces good
results.  It splits original hunks symbol-by-symbol (though word-by-word
works as well) and compares them ignoring whitespace differences.

Would you like to improve diff-mode and smerge-mode with something like this?

Index: lisp/smerge-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/smerge-mode.el,v
retrieving revision 1.53
diff -u -r1.53 smerge-mode.el
--- lisp/smerge-mode.el 9 Oct 2007 03:38:56 -0000       1.53
+++ lisp/smerge-mode.el 14 Oct 2007 21:30:03 -0000
@@ -667,22 +667,33 @@
       (insert-buffer-substring buf beg end)
       (when preproc (goto-char (point-min)) (funcall preproc))
       (goto-char (point-min))
+      (while (search-forward "\n" nil t)
+       (replace-match "" nil nil))
+      (goto-char (point-min))
       (while (not (eobp))
-        (forward-char 1)
+        (save-match-data (forward-symbol 1))
         ;; We add \n after each char except after \n, so we get one line per
         ;; text char, where each line contains just one char, except for \n
         ;; chars which are represented by the empty line.
-        (unless (eq (char-before) ?\n) (insert ?\n)))
+       (insert ?\n))
       (let ((coding-system-for-write 'emacs-mule))
         (write-region (point-min) (point-max) file nil 'nomessage)))))
 
 (defun smerge-refine-highlight-change (buf beg match-num1 match-num2 props)
   (let* ((startline (string-to-number (match-string match-num1)))
+        (len1 (1- startline))
+        (len2 (if (match-end match-num2)
+                  (string-to-number (match-string match-num2))
+                startline))
          (ol (make-overlay
-              (+ beg startline -1)
-              (+ beg (if (match-end match-num2)
-                         (string-to-number (match-string match-num2))
-                       startline))
+             (with-current-buffer buf
+               (goto-char beg)
+               (save-match-data (forward-symbol len1))
+               (point))
+             (with-current-buffer buf
+               (goto-char beg)
+               (save-match-data (forward-symbol len2))
+               (point))
               buf
               ;; Make them tend to shrink rather than spread when editing.
               'front-advance nil)))
@@ -710,7 +721,7 @@
           (let ((coding-system-for-read 'emacs-mule))
             ;; Don't forget -a to make sure diff treats it as a text file
             ;; even if it contains \0 and such.
-            (call-process diff-command nil t nil "-a" file1 file2))
+            (call-process diff-command nil t nil "-awb" file1 file2))
           ;; Process diff's output.
           (goto-char (point-min))
           (while (not (eobp))

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]