comparison lisp/smerge-mode.el @ 93442:a6d8268a0da6

(smerge-refine): Allow highlighting other subparts in 3-way conflicts.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 31 Mar 2008 01:49:57 +0000
parents ca1e1298a3d8
children 87b6e6f4a207
comparison
equal deleted inserted replaced
93441:c13d8b4cc7ad 93442:a6d8268a0da6
862 ))) 862 )))
863 (goto-char pos) 863 (goto-char pos)
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) 869 For 3-way conflicts, highlights only 2 of the 3 parts.
870 ;; FIXME: make it work with 3-way conflicts. 870 A numeric argument PART can be used to specify which 2 parts;
871 repeating 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
882 (defun smerge-diff (n1 n2) 903 (defun smerge-diff (n1 n2)
883 (smerge-match-conflict) 904 (smerge-match-conflict)