aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/smerge-mode.el39
2 files changed, 35 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0ca01a7c8f4..2c85b155cd4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12008-03-31 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * smerge-mode.el (smerge-refine): Allow highlighting other subparts
4 in 3-way conflicts.
5
12008-03-31 Glenn Morris <rgm@gnu.org> 62008-03-31 Glenn Morris <rgm@gnu.org>
2 7
3 * calendar/cal-bahai.el (calendar-bahai-date-string): Avoid an error for 8 * calendar/cal-bahai.el (calendar-bahai-date-string): Avoid an error for
diff --git a/lisp/smerge-mode.el b/lisp/smerge-mode.el
index 8a3f15bac44..ab8196c80c5 100644
--- a/lisp/smerge-mode.el
+++ b/lisp/smerge-mode.el
@@ -864,18 +864,39 @@ replace chars to try and eliminate some spurious differences."
864 (delete-file file1) 864 (delete-file file1)
865 (delete-file file2)))) 865 (delete-file file2))))
866 866
867(defun smerge-refine () 867(defun smerge-refine (&optional part)
868 "Highlight the parts of the conflict that are different." 868 "Highlight the words of the conflict that are different.
869 (interactive) 869For 3-way conflicts, highlights only 2 of the 3 parts.
870 ;; FIXME: make it work with 3-way conflicts. 870A numeric argument PART can be used to specify which 2 parts;
871repeating the command will highlight other 2 parts."
872 (interactive
873 (if (integerp current-prefix-arg) (list current-prefix-arg)
874 (smerge-match-conflict)
875 (let* ((prop (get-text-property (match-beginning 0) 'smerge-refine-part))
876 (part (if (and (consp prop)
877 (eq (buffer-chars-modified-tick) (car prop)))
878 (cdr prop))))
879 ;; If already highlighted, cycle.
880 (list (if (integerp part) (1+ (mod part 3)))))))
881
882 (if (and (integerp part) (or (< part 1) (> part 3)))
883 (error "No conflict part nb %s" part))
871 (smerge-match-conflict) 884 (smerge-match-conflict)
872 (remove-overlays (match-beginning 0) (match-end 0) 'smerge 'refine) 885 (remove-overlays (match-beginning 0) (match-end 0) 'smerge 'refine)
873 (smerge-ensure-match 1) 886 ;; Ignore `part' if not applicable, and default it if not provided.
874 (smerge-ensure-match 3) 887 (setq part (cond ((null (match-end 2)) 2)
875 ;; Match 1 and 3 may be one and the same in case of trivial diff3 -A conflict. 888 ((eq (match-end 1) (match-end 3)) 1)
876 (let ((n1 (if (eq (match-end 1) (match-end 3)) 2 1))) 889 ((integerp part) part)
890 (t 2)))
891 (let ((n1 (if (eq part 1) 2 1))
892 (n2 (if (eq part 3) 2 3)))
893 (smerge-ensure-match n1)
894 (smerge-ensure-match n2)
895 (put-text-property (match-beginning 0) (1+ (match-beginning 0))
896 'smerge-refine-part
897 (cons (buffer-chars-modified-tick) part))
877 (smerge-refine-subst (match-beginning n1) (match-end n1) 898 (smerge-refine-subst (match-beginning n1) (match-end n1)
878 (match-beginning 3) (match-end 3) 899 (match-beginning n2) (match-end n2)
879 '((smerge . refine) 900 '((smerge . refine)
880 (face . smerge-refined-change))))) 901 (face . smerge-refined-change)))))
881 902