aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-08-10 03:39:47 +0000
committerRichard M. Stallman1994-08-10 03:39:47 +0000
commit0691ced3c70e3dd8499ee51385c574db6867da41 (patch)
tree1d4a2c564041b0e08bced61f7ea4116b0838949a
parenta30f0615eb3b5f218891f1b96f22732acf2ce3de (diff)
downloademacs-0691ced3c70e3dd8499ee51385c574db6867da41.tar.gz
emacs-0691ced3c70e3dd8499ee51385c574db6867da41.zip
(ediff-find-file, ediff-patch-file): Handle symlinks.
Check ediff-if-lucid when setting up Emacs 19 menus. (ediff-save-buffer): Added option for saving diff output. (ediff-fine-diff-buffer, ediff-ignore-similar-regions): New variables. (ediff-no-fine-diffs): Macro added. (ediff-next-difference, ediff-previous-difference) (ediff-make-fine-diffs): Enabled a new feature that allows one to skip over the difference regions where the only differences are the white space and newlines. (ediff-toggle-autorefine): Fixed a bug that caused error when the current difference is <= 0 or > ediff-number-of-differences.
-rw-r--r--lisp/ediff.el542
1 files changed, 343 insertions, 199 deletions
diff --git a/lisp/ediff.el b/lisp/ediff.el
index b8d48a2bd95..b997674fb3c 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -3,7 +3,7 @@
3 3
4;; Author: Michael Kifer <kifer@cs.sunysb.edu> 4;; Author: Michael Kifer <kifer@cs.sunysb.edu>
5;; Created: February 2, 1994 5;; Created: February 2, 1994
6;; Version of last Kifer changes: 1.64.2 6;; Version: 1.65c
7;; Keywords: comparing, merging, patching, version control. 7;; Keywords: comparing, merging, patching, version control.
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -300,6 +300,27 @@
300;; which regexps are being used, the status command, `i', will supply 300;; which regexps are being used, the status command, `i', will supply
301;; the requisite information. 301;; the requisite information.
302;; 302;;
303;; In addition to the ability to ignore regions that match regular
304;; expressions, Ediff can be ordered to start skipping over certain
305;; `inessential' regions. This is controlled by the variable
306;;
307;; ediff-ignore-similar-regions
308;;
309;; which, if set to t, will cause Ediff to skip over difference regions
310;; that has been found similar, i.e., where the only differences are those
311;; in the white space and newlines.
312;;
313;; Note: In order for this feature to work, auto-refining of difference
314;; regions must be on, since otherwise Ediff won't know if there are no
315;; fine differences between regions. Under X, auto-refining is a default,
316;; but it is nixed on a dumb terminal or in an Xterm window. Therefore, in
317;; a non-windowing environment, the user must explicitly turn
318;; auto-refining on (e.g., by typing `@').
319;;
320;; CAUTION: If many inessential regions appear in a row, Ediff may take a
321;; long time to jump to the next region because it has to compute fine
322;; differences of all intermediate regions.
323;;
303;; 324;;
304;; Highlighting difference regions 325;; Highlighting difference regions
305;; ------------------------------- 326;; -------------------------------
@@ -453,11 +474,12 @@
453;; diff to ignore spaces and such. Use the option '-w' for that. Diff 474;; diff to ignore spaces and such. Use the option '-w' for that. Diff
454;; has several other useful options (type 'man diff' to find out). 475;; has several other useful options (type 'man diff' to find out).
455;; 476;;
456;; The output from diff is found in *ediff-diff* buffer. However, this 477;; The output from diff is found in *ediff-diff* buffer, which you can save.
457;; makes sense only if you also intend to use Ediff to browse through the 478;; However, using Ediff for producing a diff output makes sense only if you
458;; diff'ed files before sending the patch. This is because diff.el is much 479;; also intend to use Ediff to browse through the diff'ed files before
459;; faster in yielding the output of diff (Ediff is a big gun, if used 480;; sending the patch. This is because diff.el, which also comes with
460;; for this simple purpose). 481;; Emacs, is much faster in yielding the output of diff (Ediff is a big
482;; gun, if used for this simple purpose).
461;; 483;;
462;; Mode line 484;; Mode line
463;; --------- 485;; ---------
@@ -533,6 +555,12 @@
533;; 555;;
534;; The total number of differences and the current difference number are 556;; The total number of differences and the current difference number are
535;; always displayed in the mode line of the control window. 557;; always displayed in the mode line of the control window.
558;;
559;; If, after making changes to buffers A and B, you decide to save them, it
560;; is recommended to use `ediff-save-buffer', which is bound to `wa' and
561;; `wb' (`wa will save buffer A and `wb' saves buffer B).
562;;
563;; Typing `wf' will also save the diff output in a file.
536 564
537;;; Display Modes 565;;; Display Modes
538;; ------------- 566;; -------------
@@ -899,6 +927,18 @@
899;; will accommodate the way buffers are identified in mode-line.el and 927;; will accommodate the way buffers are identified in mode-line.el and
900;; uniquify.el. 928;; uniquify.el.
901 929
930;; Fri August 5, 1994
931
932;; Ediff can now automatically skip over regions that differ only in
933;; the white space and line breaks. This is controled with the variable
934;; `ediff-ignore-similar-regions' and can be toggled on/off by typing
935;; `##'.
936
937;; Mon August 8, 1994
938
939;; If ediff-save-buffer is invoked with `wf', it'll save the diff
940;; output in a file.
941
902 942
903;;; Acknowledgements: 943;;; Acknowledgements:
904 944
@@ -954,6 +994,13 @@
954(defmacro ediff-get-difference (n) 994(defmacro ediff-get-difference (n)
955 (` (aref ediff-difference-vector (, n)))) 995 (` (aref ediff-difference-vector (, n))))
956 996
997;; tell if it has been previously found that the region doesn't
998;; contain diffs other than the white space and newlines
999;; The argument, N, is the diff region number used by Ediff to index the
1000;; diff vector. It is 1 less than the number seen by the user.
1001(defmacro ediff-no-fine-diffs (n)
1002 (` (aref (ediff-get-difference n) 3)))
1003
957(defmacro ediff-get-diff-overlay-from-vector (vec buf-type) 1004(defmacro ediff-get-diff-overlay-from-vector (vec buf-type)
958 (` (aref (, vec) 1005 (` (aref (, vec)
959 (cond ((eq (, buf-type) 'A) 0) 1006 (cond ((eq (, buf-type) 'A) 0)
@@ -971,10 +1018,18 @@
971 1018
972(defmacro ediff-set-fine-diff-vector (n fine-vec) 1019(defmacro ediff-set-fine-diff-vector (n fine-vec)
973 (` (aset (ediff-get-difference (, n)) 2 (, fine-vec)))) 1020 (` (aset (ediff-get-difference (, n)) 2 (, fine-vec))))
1021
1022;; if flag is t, puts a mark on diff region saying that
1023;; the differences are in white space only. If flag is nil,
1024;; the region is marked as essential (i.e., differences are
1025;; not just in the white space and newlines.)
1026(defmacro ediff-mark-diff-as-space-only (n flag)
1027 (` (aset (ediff-get-difference (, n)) 3 (, flag))))
974 1028
975(defmacro ediff-get-fine-diff-vector (n) 1029(defmacro ediff-get-fine-diff-vector (n)
976 (` (ediff-get-fine-diff-vector-from-vec (ediff-get-difference (, n))))) 1030 (` (ediff-get-fine-diff-vector-from-vec (ediff-get-difference (, n)))))
977 1031
1032
978(defmacro ediff-defvar-local (var value doc) 1033(defmacro ediff-defvar-local (var value doc)
979 "Defines SYMBOL as an advertised local variable. 1034 "Defines SYMBOL as an advertised local variable.
980Performs a defvar, then executes `make-variable-buffer-local' on 1035Performs a defvar, then executes `make-variable-buffer-local' on
@@ -1058,16 +1113,21 @@ on ediff-quit or ediff-suspend.")
1058;; Help messages 1113;; Help messages
1059 1114
1060(defconst ediff-help-message-long 1115(defconst ediff-help-message-long
1061 "p,DEL - prev diff v/V - scroll up/dn ab - diff A to B * - refine diff 1116 " Moving around | Toggling features | Miscellaneous
1062n,SPC - next diff </> - scroll lt/rt ba - diff B to A ! - recomp diffs 1117=======================|===========================|===========================
1063 j - jump to diff s - toggle split ra - restore A i - status info 1118p,DEL -previous diff | s -vert/horiz split | ab/ba -copy diff A->B/B->A
1064ga/gb - goto pt in A/B h - toggle hilit rb - restore B z - suspend Ediff 1119n,SPC -next diff | h -hiliting | ra/rb -restore diff in A/B
1065 c - recenter @ - toggle refine q - quit Ediff 1120 j -jump to diff | @ -auto-refining | * -refine diff
1066 #f/#h - toggle focus/hide diff regions 1121ga/gb -to point in A/B |---------------------------| ! -recompute diffs
1067wa/wb - save buf A/B A/B - toggle read-only in buffers A/B ? - toggle help") 1122 c -recenter | ## -skip whitespace |---------------------------
1123 v/V -scroll up/down | #f/#h -focus/hide regions | wa/wb -save buf A/B
1124 </> -scroll lft/rght | A/B -read-only buf A/B | wf -save diff output
1125=======================|===========================|===========================
1126 i -status info | ? -toggle help window | z/q -suspend/quit Ediff"
1127 )
1068 1128
1069(defconst ediff-help-message-short 1129(defconst ediff-help-message-short
1070 " ? - toggle help window") 1130 " ? - toggle help window")
1071 1131
1072(defvar ediff-help-message ediff-help-message-long 1132(defvar ediff-help-message ediff-help-message-long
1073 "*The actual help message.") 1133 "*The actual help message.")
@@ -1113,17 +1173,21 @@ See `ediff-word-1' for more details.")
1113 1173
1114;; Selective browsing 1174;; Selective browsing
1115 1175
1116(defconst ediff-skip-diff-region-function 'ediff-show-all-diffs 1176(ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs
1117 "Function that determines the next/previous diff region to show.") 1177 "Function that determines the next/previous diff region to show.
1178Should return t for regions to be ignored and nil otherwise.
1179This function gets a region number as an argument. The region number
1180is the one used internally by Ediff. It is 1 less than the number seen
1181by the user.")
1118 1182
1119(defconst ediff-regexp-focus-A "" 1183(ediff-defvar-local ediff-regexp-focus-A ""
1120 "Regexp that determines buf A regions to focus on when skipping to diff.") 1184 "Regexp that determines buf A regions to focus on when skipping to diff.")
1121(defconst ediff-regexp-focus-B "" 1185(ediff-defvar-local ediff-regexp-focus-B ""
1122 "Regexp that determines buf B regions to focus on when skipping to diff.") 1186 "Regexp that determines buf B regions to focus on when skipping to diff.")
1123 1187
1124(defconst ediff-regexp-hide-A "" 1188(ediff-defvar-local ediff-regexp-hide-A ""
1125 "Regexp that determines buf A regions to ignore when skipping to diff.") 1189 "Regexp that determines buf A regions to ignore when skipping to diff.")
1126(defconst ediff-regexp-hide-B "" 1190(ediff-defvar-local ediff-regexp-hide-B ""
1127 "Regexp that determines buf B regions to ignore when skipping to diff.") 1191 "Regexp that determines buf B regions to ignore when skipping to diff.")
1128 1192
1129 1193
@@ -1230,7 +1294,7 @@ This variable must be set before Ediff is loaded. If you don't like the
1230look of the default menus, set this variable to nil and make your own 1294look of the default menus, set this variable to nil and make your own
1231menus.") 1295menus.")
1232 1296
1233(ediff-defvar-local ediff-auto-refine 'on 1297(ediff-defvar-local ediff-auto-refine (if window-system 'on 'nix)
1234 "If `'on', Ediff auto-highlights fine diffs for the current diff region. 1298 "If `'on', Ediff auto-highlights fine diffs for the current diff region.
1235If `off', auto-highlighting is not used. If `'nix', no fine diffs are shown 1299If `off', auto-highlighting is not used. If `'nix', no fine diffs are shown
1236at all, unless the user force-refines the region by hitting `*'. 1300at all, unless the user force-refines the region by hitting `*'.
@@ -1238,6 +1302,9 @@ at all, unless the user force-refines the region by hitting `*'.
1238This variable can be set either in .emacs or toggled interactively, using 1302This variable can be set either in .emacs or toggled interactively, using
1239ediff-toggle-hilit.") 1303ediff-toggle-hilit.")
1240 1304
1305(ediff-defvar-local ediff-ignore-similar-regions nil
1306 "*If t, skip over difference regions that differ only in the white space and line breaks.")
1307
1241(ediff-defvar-local ediff-auto-refine-limit 700 1308(ediff-defvar-local ediff-auto-refine-limit 700
1242 "Auto-refine only those regions that are smaller than this number of bytes.") 1309 "Auto-refine only those regions that are smaller than this number of bytes.")
1243 1310
@@ -1300,6 +1367,8 @@ overlay's endpoints coincide. ")
1300(ediff-defvar-local ediff-diff-buffer nil 1367(ediff-defvar-local ediff-diff-buffer nil
1301 "Buffer containing the output of diff, which is used by Ediff to step 1368 "Buffer containing the output of diff, which is used by Ediff to step
1302through files.") 1369through files.")
1370(ediff-defvar-local ediff-fine-diff-buffer nil
1371 "Buffer used for diff-style fine differences between regions.")
1303(ediff-defvar-local ediff-tmp-buffer nil 1372(ediff-defvar-local ediff-tmp-buffer nil
1304 "Temporary buffer used for computing fine differences.") 1373 "Temporary buffer used for computing fine differences.")
1305(ediff-defvar-local ediff-error-buffer nil 1374(ediff-defvar-local ediff-error-buffer nil
@@ -1537,9 +1606,9 @@ through files.")
1537 ;;; Overlays 1606 ;;; Overlays
1538 1607
1539 (ediff-defvar-local ediff-current-diff-overlay-A nil 1608 (ediff-defvar-local ediff-current-diff-overlay-A nil
1540 "Overlay in buffer A.") 1609 "Overlay specifying the current difference region in buffer A.")
1541 (ediff-defvar-local ediff-current-diff-overlay-B nil 1610 (ediff-defvar-local ediff-current-diff-overlay-B nil
1542 "Overlay in buffer B.") 1611 "Overlay specifying the current difference region in buffer B.")
1543 1612
1544 (defun ediff-make-current-diff-overlay (type) 1613 (defun ediff-make-current-diff-overlay (type)
1545 (let ((overlay (if (eq type 'A) 1614 (let ((overlay (if (eq type 'A)
@@ -1654,7 +1723,7 @@ Do not start with `~/' or `~user-name/'.")
1654;;; purify-flag make these no-ops when you load ediff. 1723;;; purify-flag make these no-ops when you load ediff.
1655;;; They only do something in loaddefs.el. 1724;;; They only do something in loaddefs.el.
1656;;;###autoload 1725;;;###autoload
1657(if purify-flag 1726(if (and purify-flag (not (ediff-if-lucid)))
1658 (progn 1727 (progn
1659 (defvar menu-bar-epatch-menu (make-sparse-keymap "Epatch")) 1728 (defvar menu-bar-epatch-menu (make-sparse-keymap "Epatch"))
1660 (fset 'menu-bar-epatch-menu (symbol-value 'menu-bar-epatch-menu)) 1729 (fset 'menu-bar-epatch-menu (symbol-value 'menu-bar-epatch-menu))
@@ -1663,39 +1732,44 @@ Do not start with `~/' or `~user-name/'.")
1663 1732
1664 1733
1665;;;###autoload 1734;;;###autoload
1666(if purify-flag 1735(if (and purify-flag (not (ediff-if-lucid)))
1667 (progn 1736 (progn
1668 (define-key menu-bar-ediff-menu [rcs-ediff] 1737 (define-key menu-bar-ediff-menu [rcs-ediff]
1669 '("Compare with a version via RCS ..." . rcs-ediff)) 1738 '("File with a version via RCS ..." . rcs-ediff))
1670 (define-key menu-bar-ediff-menu [vc-ediff] 1739 (define-key menu-bar-ediff-menu [vc-ediff]
1671 '("Compare with a version via VC ..." . vc-ediff)) 1740 '("File with a version via VC ..." . vc-ediff))
1672 (define-key menu-bar-ediff-menu [ediff-buffers] 1741 (define-key menu-bar-ediff-menu [ediff-buffers]
1673 '("Compare buffers ..." . ediff-buffers)) 1742 '("Buffers ..." . ediff-buffers))
1674 (define-key menu-bar-ediff-menu [ediff-files] 1743 (define-key menu-bar-ediff-menu [ediff-files]
1675 '("Compare files ..." . ediff-files)))) 1744 '("Files ..." . ediff-files))))
1676 1745
1677;;;###autoload 1746;;;###autoload
1678(if purify-flag 1747(if (and purify-flag (not (ediff-if-lucid)))
1679 (progn 1748 (progn
1680 (define-key menu-bar-epatch-menu [ediff-patch-buffer] 1749 (define-key menu-bar-epatch-menu [ediff-patch-buffer]
1681 '("To a Buffer ..." . ediff-patch-buffer)) 1750 '("To a Buffer ..." . ediff-patch-buffer))
1682 (define-key menu-bar-epatch-menu [ediff-patch-file] 1751 (define-key menu-bar-epatch-menu [ediff-patch-file]
1683 '("To a File ..." . ediff-patch-file)))) 1752 '("To a File ..." . ediff-patch-file))))
1753
1754(define-key menu-bar-file-menu [epatch]
1755 '("Apply Patch" . menu-bar-epatch-menu))
1756(define-key menu-bar-file-menu [ediff]
1757 '("Compare" . menu-bar-ediff-menu))
1684 1758
1685(if (and window-system ediff-want-default-menus (ediff-frame-has-menubar) 1759(if (and window-system ediff-want-default-menus (ediff-frame-has-menubar)
1686 (ediff-if-lucid)) 1760 (ediff-if-lucid))
1687 (progn ;; Lucid menu bars 1761 (progn ;; Lucid menu bars
1688 (defvar ediff-menu 1762 (defvar ediff-menu
1689 '("" 1763 '(""
1690 ["Compare files ..." ediff-files t] 1764 ["Files ..." ediff-files t]
1691 ["Compare buffers ..." ediff-buffers t] 1765 ["Buffers ..." ediff-buffers t]
1692 ["Compare with a version via VC ..." vc-ediff t] 1766 ["File with a version via VC ..." vc-ediff t]
1693 ["Compare with a version via RCS ..." rcs-ediff t])) 1767 ["File with a version via RCS ..." rcs-ediff t]))
1694 (defvar epatch-menu 1768 (defvar epatch-menu
1695 '("" 1769 '(""
1696 ["To a file ..." ediff-patch-file t] 1770 ["To a file ..." ediff-patch-file t]
1697 ["To a buffer ..." ediff-patch-buffer t])) 1771 ["To a buffer ..." ediff-patch-buffer t]))
1698 (add-menu '("File") "Compare files" 1772 (add-menu '("File") "Compare"
1699 ediff-menu 1773 ediff-menu
1700 "New Screen") 1774 "New Screen")
1701 (add-menu '("File") "Apply Patch" 1775 (add-menu '("File") "Apply Patch"
@@ -1748,14 +1822,16 @@ Do not start with `~/' or `~user-name/'.")
1748 (define-key ediff-mode-map "#" nil) 1822 (define-key ediff-mode-map "#" nil)
1749 (define-key ediff-mode-map "#h" 'ediff-toggle-regexp-match) 1823 (define-key ediff-mode-map "#h" 'ediff-toggle-regexp-match)
1750 (define-key ediff-mode-map "#f" 'ediff-toggle-regexp-match) 1824 (define-key ediff-mode-map "#f" 'ediff-toggle-regexp-match)
1825 (define-key ediff-mode-map "##" 'ediff-toggle-skip-similar)
1751 (define-key ediff-mode-map "o" nil) 1826 (define-key ediff-mode-map "o" nil)
1752 (define-key ediff-mode-map "A" 'ediff-toggle-read-only) 1827 (define-key ediff-mode-map "A" 'ediff-toggle-read-only)
1753 (define-key ediff-mode-map "B" 'ediff-toggle-read-only) 1828 (define-key ediff-mode-map "B" 'ediff-toggle-read-only)
1754 (define-key ediff-mode-map "w" nil) 1829 (define-key ediff-mode-map "w" nil)
1755 (define-key ediff-mode-map "wa" 'ediff-save-buffer) 1830 (define-key ediff-mode-map "wa" 'ediff-save-buffer)
1756 (define-key ediff-mode-map "wb" 'ediff-save-buffer) 1831 (define-key ediff-mode-map "wb" 'ediff-save-buffer)
1832 (define-key ediff-mode-map "wf" 'ediff-save-buffer)
1757 (define-key ediff-mode-map "k" nil) 1833 (define-key ediff-mode-map "k" nil)
1758 (define-key ediff-mode-map "kkk" 'ediff-reload-keymap) ;; for debug 1834 (define-key ediff-mode-map "kkk" 'ediff-reload-keymap) ;; for debugging
1759 ;; Allow ediff-mode-map to be referenced indirectly 1835 ;; Allow ediff-mode-map to be referenced indirectly
1760 (fset 'ediff-mode-map ediff-mode-map)) 1836 (fset 'ediff-mode-map ediff-mode-map))
1761 1837
@@ -1794,7 +1870,8 @@ Arguments: (file buffer &optional last-dir hooks)"
1794 (set hooks-var (cons (` (lambda () (delete-file (, file)))) 1870 (set hooks-var (cons (` (lambda () (delete-file (, file))))
1795 (eval hooks-var)))) 1871 (eval hooks-var))))
1796 ;; file processed via auto-mode-alist, a la uncompress.el 1872 ;; file processed via auto-mode-alist, a la uncompress.el
1797 ((not (equal (expand-file-name file) (buffer-file-name))) 1873 ((not (equal (file-truename file)
1874 (file-truename (buffer-file-name))))
1798 (setq file (ediff-make-temp-file)) 1875 (setq file (ediff-make-temp-file))
1799 (set hooks-var (cons (` (lambda () (delete-file (, file)))) 1876 (set hooks-var (cons (` (lambda () (delete-file (, file))))
1800 (eval hooks-var)))) 1877 (eval hooks-var))))
@@ -1920,9 +1997,13 @@ Else, read patch file into a new buffer."
1920 1997
1921 (or use-old (setq ediff-diff-buffer 1998 (or use-old (setq ediff-diff-buffer
1922 (get-buffer-create 1999 (get-buffer-create
1923 (emerge-unique-buffer-name "*ediff-diff" "*")))) 2000 (emerge-unique-buffer-name "*ediff-diff" "*"))
2001 ediff-fine-diff-buffer
2002 (get-buffer-create
2003 (emerge-unique-buffer-name "*ediff-fine-diff" "*"))
2004 ))
1924 (ediff-eval-in-buffer 2005 (ediff-eval-in-buffer
1925 ediff-diff-buffer 2006 (if refine-region ediff-fine-diff-buffer ediff-diff-buffer)
1926 (erase-buffer) 2007 (erase-buffer)
1927 ;; shell-command tends to display old shell command buffers even when it 2008 ;; shell-command tends to display old shell command buffers even when it
1928 ;; puts output in another buffer---probably an Emacs bug. 2009 ;; puts output in another buffer---probably an Emacs bug.
@@ -1938,28 +2019,30 @@ Else, read patch file into a new buffer."
1938 (ediff-protect-metachars file-B)) 2019 (ediff-protect-metachars file-B))
1939 t) 2020 t)
1940 )) 2021 ))
1941 (ediff-prepare-error-list diff-ok-lines-regexp) 2022
1942 (if refine-region 2023
1943 (message "Refining difference region %d ... Done." (1+ refine-region))
1944 (message "Computing differences ... Done.")(sit-for .5))
1945 (if refine-region 2024 (if refine-region
1946 (ediff-convert-diffs-to-overlays-refine 2025 (progn
1947 ediff-A-buffer ediff-B-buffer 2026 (ediff-prepare-error-list diff-ok-lines-regexp ediff-fine-diff-buffer)
1948 (ediff-extract-diffs ediff-diff-buffer) 2027 (message "Refining difference region %d ... Done." (1+ refine-region))
1949 refine-region) 2028 (ediff-convert-diffs-to-overlays-refine
2029 ediff-A-buffer ediff-B-buffer
2030 (ediff-extract-diffs ediff-fine-diff-buffer)
2031 refine-region))
2032 (ediff-prepare-error-list diff-ok-lines-regexp ediff-diff-buffer)
2033 (message "Computing differences ... Done.")(sit-for .5)
1950 (ediff-convert-diffs-to-overlays 2034 (ediff-convert-diffs-to-overlays
1951 ediff-A-buffer ediff-B-buffer 2035 ediff-A-buffer ediff-B-buffer
1952 (ediff-extract-diffs ediff-diff-buffer ediff-A-buffer ediff-B-buffer))) 2036 (ediff-extract-diffs ediff-diff-buffer
1953 ) 2037 ediff-A-buffer ediff-B-buffer))))
1954 2038
1955 2039
1956(defun ediff-prepare-error-list (ok-regexp) 2040(defun ediff-prepare-error-list (ok-regexp diff-buff)
1957 (let ((diff-buff ediff-diff-buffer))
1958 (ediff-eval-in-buffer 2041 (ediff-eval-in-buffer
1959 ediff-error-buffer 2042 ediff-error-buffer
1960 (erase-buffer) 2043 (erase-buffer)
1961 (insert-buffer diff-buff) 2044 (insert-buffer diff-buff)
1962 (delete-matching-lines ok-regexp)))) 2045 (delete-matching-lines ok-regexp)))
1963 2046
1964;;; Function to start Ediff by patching a file 2047;;; Function to start Ediff by patching a file
1965 2048
@@ -2002,8 +2085,8 @@ Else, read patch file into a new buffer."
2002 2085
2003 ;; Check if source file name has triggered black magic, such as file name 2086 ;; Check if source file name has triggered black magic, such as file name
2004 ;; handlers or auto mode alist, and make a note of it. 2087 ;; handlers or auto mode alist, and make a note of it.
2005 (setq file-name-magic-p (not (equal (expand-file-name true-source-filename) 2088 (setq file-name-magic-p (not (equal (file-truename true-source-filename)
2006 (expand-file-name source-filename)))) 2089 (file-truename source-filename))))
2007 2090
2008 (ediff-eval-in-buffer 2091 (ediff-eval-in-buffer
2009 ediff-patch-diagnostics 2092 ediff-patch-diagnostics
@@ -2166,8 +2249,7 @@ With prefix argument, prompts for a revision name."
2166 (buff (concat (file-name-nondirectory filename) ".~" rev "~"))) 2249 (buff (concat (file-name-nondirectory filename) ".~" rev "~")))
2167 (message "Working...") 2250 (message "Working...")
2168 (setq filename (expand-file-name filename)) 2251 (setq filename (expand-file-name filename))
2169 (with-output-to-temp-buffer 2252 (with-output-to-temp-buffer buff
2170 buff
2171 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff))) 2253 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
2172 (delete-windows-on output-buffer) 2254 (delete-windows-on output-buffer)
2173 (save-excursion 2255 (save-excursion
@@ -2548,7 +2630,7 @@ and `auto-save' properties in buffer local variables. Turns off
2548 b-begin (aref list-element 2) 2630 b-begin (aref list-element 2)
2549 b-end (aref list-element 3)) 2631 b-end (aref list-element 3))
2550 2632
2551 ;; Put overlays at the appropriate places in the buffers 2633 ;; Put overlays at appropriate places in buffers
2552 (setq a-overlay (ediff-make-overlay a-begin a-end A-buffer)) 2634 (setq a-overlay (ediff-make-overlay a-begin a-end A-buffer))
2553 ;; Priorities of overlays should be equal in all ediff control 2635 ;; Priorities of overlays should be equal in all ediff control
2554 ;; panels buffers. Otherwise it won't work due to Emacs 2636 ;; panels buffers. Otherwise it won't work due to Emacs
@@ -2590,8 +2672,10 @@ and `auto-save' properties in buffer local variables. Turns off
2590 2672
2591 ;; record all overlays for this difference 2673 ;; record all overlays for this difference
2592 (setq diff-overlay-list 2674 (setq diff-overlay-list
2593 (nconc diff-overlay-list (list (vector a-overlay b-overlay nil))) 2675 (nconc diff-overlay-list
2594 diff-list (cdr diff-list)) 2676 (list (vector a-overlay b-overlay nil nil)))
2677 diff-list
2678 (cdr diff-list))
2595 (message "Processing diff region %d of %d" 2679 (message "Processing diff region %d of %d"
2596 current-diff total-diffs) 2680 current-diff total-diffs)
2597 ) ;; while 2681 ) ;; while
@@ -2725,19 +2809,18 @@ On a dumb terminal, switches between ASCII highlighting and no highlighting."
2725(defun ediff-toggle-autorefine () 2809(defun ediff-toggle-autorefine ()
2726 "Toggle auto-refine mode." 2810 "Toggle auto-refine mode."
2727 (interactive) 2811 (interactive)
2728 (if window-system 2812 (cond ((eq ediff-auto-refine 'nix)
2729 (cond ((eq ediff-auto-refine 'nix) 2813 (setq ediff-auto-refine 'on)
2730 (setq ediff-auto-refine 'on) 2814 (ediff-make-fine-diffs ediff-current-difference 'noforce)
2731 (ediff-make-fine-diffs ediff-current-difference 'noforce) 2815 (message "Auto-refining is ON."))
2732 (message "Auto-refining is ON.")) 2816 ((eq ediff-auto-refine 'on)
2733 ((eq ediff-auto-refine 'on) 2817 (message "Auto-refining is OFF.")
2734 (message "Auto-refining is OFF.") 2818 (setq ediff-auto-refine 'off))
2735 (setq ediff-auto-refine 'off)) 2819 (t
2736 (t 2820 (ediff-set-fine-diff-properties ediff-current-difference 'default)
2737 (ediff-set-fine-diff-properties ediff-current-difference 'default) 2821 (message "Refinements are HIDDEN.")
2738 (message "Refinements are HIDDEN.") 2822 (setq ediff-auto-refine 'nix))
2739 (setq ediff-auto-refine 'nix)) 2823 ))
2740 )))
2741 2824
2742(defun ediff-toggle-help () 2825(defun ediff-toggle-help ()
2743 "Toggle short/long help message." 2826 "Toggle short/long help message."
@@ -2929,9 +3012,19 @@ With a prefix argument, go back that many differences."
2929 (let ((n (min ediff-number-of-differences 3012 (let ((n (min ediff-number-of-differences
2930 (+ ediff-current-difference (if arg arg 1)))) 3013 (+ ediff-current-difference (if arg arg 1))))
2931 (buffer-read-only nil)) 3014 (buffer-read-only nil))
2932 (while (funcall ediff-skip-diff-region-function n) 3015
3016 (while (and (< n ediff-number-of-differences)
3017 (funcall ediff-skip-diff-region-function n))
2933 (setq n (1+ n))) 3018 (setq n (1+ n)))
2934 (ediff-unselect-and-select-difference n)) 3019
3020 (ediff-unselect-and-select-difference n)
3021 ;; possibly skip inessential difference regions
3022 (while (and ediff-ignore-similar-regions
3023 (< n ediff-number-of-differences)
3024 (ediff-no-fine-diffs n))
3025 (setq n (1+ n))
3026 (ediff-unselect-and-select-difference n))
3027 ) ;; let
2935 (error "At end of the difference list."))) 3028 (error "At end of the difference list.")))
2936 3029
2937(defun ediff-previous-difference (&optional arg) 3030(defun ediff-previous-difference (&optional arg)
@@ -2941,9 +3034,18 @@ With a prefix argument, go back that many differences."
2941 (if (> ediff-current-difference -1) 3034 (if (> ediff-current-difference -1)
2942 (let ((n (max -1 (- ediff-current-difference (if arg arg 1)))) 3035 (let ((n (max -1 (- ediff-current-difference (if arg arg 1))))
2943 (buffer-read-only nil)) 3036 (buffer-read-only nil))
2944 (while (funcall ediff-skip-diff-region-function n) 3037
3038 (while (and (funcall ediff-skip-diff-region-function n)
3039 (> n -1))
2945 (setq n (1- n))) 3040 (setq n (1- n)))
2946 (ediff-unselect-and-select-difference n)) 3041 (ediff-unselect-and-select-difference n)
3042 ;; possibly skip inessential difference regions
3043 (while (and ediff-ignore-similar-regions
3044 (> n -1)
3045 (ediff-no-fine-diffs n))
3046 (setq n (1- n))
3047 (ediff-unselect-and-select-difference n))
3048 ) ;; let
2947 (error "At beginning of the difference list."))) 3049 (error "At beginning of the difference list.")))
2948 3050
2949(defun ediff-jump-to-difference (difference-number) 3051(defun ediff-jump-to-difference (difference-number)
@@ -3181,7 +3283,7 @@ ARG is a prefix argument. If ARG is nil, restore current-difference."
3181 (ediff-recenter 'no-rehighlight)) 3283 (ediff-recenter 'no-rehighlight))
3182 3284
3183(defun ediff-toggle-regexp-match () 3285(defun ediff-toggle-regexp-match ()
3184 "Focus on difference regions that match a regexp or hide those diffs." 3286 "Toggle focus on difference regions that match a regexp or hide those diffs."
3185 (interactive) 3287 (interactive)
3186 (let (regexp-A regexp-B) 3288 (let (regexp-A regexp-B)
3187 (cond 3289 (cond
@@ -3189,7 +3291,7 @@ ARG is a prefix argument. If ARG is nil, restore current-difference."
3189 (eq last-command-char ?f)) 3291 (eq last-command-char ?f))
3190 (and (eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) 3292 (and (eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches)
3191 (eq last-command-char ?h))) 3293 (eq last-command-char ?h)))
3192 (message "Show all difference regions.") 3294 (message "Selective browsing by regexp turned off.")
3193 (setq ediff-skip-diff-region-function 'ediff-show-all-diffs)) 3295 (setq ediff-skip-diff-region-function 'ediff-show-all-diffs))
3194 ((eq last-command-char ?h) 3296 ((eq last-command-char ?h)
3195 (setq ediff-skip-diff-region-function 'ediff-hide-regexp-matches 3297 (setq ediff-skip-diff-region-function 'ediff-hide-regexp-matches
@@ -3221,6 +3323,13 @@ ARG is a prefix argument. If ARG is nil, restore current-difference."
3221 (message "Focus on difference regions matching regexp.") 3323 (message "Focus on difference regions matching regexp.")
3222 (or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A)) 3324 (or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A))
3223 (or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B)))))) 3325 (or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B))))))
3326
3327(defun ediff-toggle-skip-similar ()
3328 (interactive)
3329 (setq ediff-ignore-similar-regions (not ediff-ignore-similar-regions))
3330 (if ediff-ignore-similar-regions
3331 (message "Skipping over regions that differ only in white space & line breaks.")
3332 (message "Skipping over white-space differences turned off.")))
3224 3333
3225(defun ediff-show-all-diffs (n) 3334(defun ediff-show-all-diffs (n)
3226 "Don't skip difference regions." 3335 "Don't skip difference regions."
@@ -3231,22 +3340,27 @@ ARG is a prefix argument. If ARG is nil, restore current-difference."
3231Regions to be ignored according to this function are those where 3340Regions to be ignored according to this function are those where
3232buf A region doesn't match `ediff-regexp-focus-A' and buf B region 3341buf A region doesn't match `ediff-regexp-focus-A' and buf B region
3233doesn't match `ediff-regexp-focus-B'. 3342doesn't match `ediff-regexp-focus-B'.
3234This function should return nil for regions not to be ignored and t for 3343This function returns nil if the region number N (specified as
3235regions to be ignored." 3344an argument) is not to be ignored and t if region N is to be ignored.
3345
3346N is a region number used by Ediff internally. It is 1 less
3347the number seen by the user."
3236 (if (and (>= n 0) (< n ediff-number-of-differences)) 3348 (if (and (>= n 0) (< n ediff-number-of-differences))
3237 (let* ((ctl-buf ediff-control-buffer) 3349 (let* ((ctl-buf ediff-control-buffer)
3350 (regex-A ediff-regexp-focus-A)
3351 (regex-B ediff-regexp-focus-B)
3238 (reg-A-match (ediff-eval-in-buffer 3352 (reg-A-match (ediff-eval-in-buffer
3239 ediff-A-buffer 3353 ediff-A-buffer
3240 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) 3354 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf))
3241 (re-search-forward 3355 (re-search-forward
3242 ediff-regexp-focus-A 3356 regex-A
3243 (ediff-get-diff-posn 'A 'end n ctl-buf) 3357 (ediff-get-diff-posn 'A 'end n ctl-buf)
3244 t))) 3358 t)))
3245 (reg-B-match (ediff-eval-in-buffer 3359 (reg-B-match (ediff-eval-in-buffer
3246 ediff-B-buffer 3360 ediff-B-buffer
3247 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) 3361 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf))
3248 (re-search-forward 3362 (re-search-forward
3249 ediff-regexp-focus-B 3363 regex-B
3250 (ediff-get-diff-posn 'B 'end n ctl-buf) 3364 (ediff-get-diff-posn 'B 'end n ctl-buf)
3251 t)))) 3365 t))))
3252 (not (and reg-A-match reg-B-match))))) 3366 (not (and reg-A-match reg-B-match)))))
@@ -3255,22 +3369,27 @@ regions to be ignored."
3255 "Hide diffs that match regexp `ediff-regexp-hide-A/B'. 3369 "Hide diffs that match regexp `ediff-regexp-hide-A/B'.
3256Regions to be ignored are those where buf A region matches 3370Regions to be ignored are those where buf A region matches
3257`ediff-regexp-hide-A' and buf B region matches `ediff-regexp-hide-B'. 3371`ediff-regexp-hide-A' and buf B region matches `ediff-regexp-hide-B'.
3258This function returns nil for regions not to be ignored and t for regions 3372This function returns nil if the region number N (specified as
3259to be ignored." 3373an argument) is not to be ignored and t if region N is to be ignored.
3374
3375N is a region number used by Ediff internally. It is 1 less
3376the number seen by the user."
3260 (if (and (>= n 0) (< n ediff-number-of-differences)) 3377 (if (and (>= n 0) (< n ediff-number-of-differences))
3261 (let* ((ctl-buf ediff-control-buffer) 3378 (let* ((ctl-buf ediff-control-buffer)
3379 (regex-A ediff-regexp-hide-A)
3380 (regex-B ediff-regexp-hide-B)
3262 (reg-A-match (ediff-eval-in-buffer 3381 (reg-A-match (ediff-eval-in-buffer
3263 ediff-A-buffer 3382 ediff-A-buffer
3264 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) 3383 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf))
3265 (re-search-forward 3384 (re-search-forward
3266 ediff-regexp-hide-A 3385 regex-A
3267 (ediff-get-diff-posn 'A 'end n ctl-buf) 3386 (ediff-get-diff-posn 'A 'end n ctl-buf)
3268 t))) 3387 t)))
3269 (reg-B-match (ediff-eval-in-buffer 3388 (reg-B-match (ediff-eval-in-buffer
3270 ediff-B-buffer 3389 ediff-B-buffer
3271 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) 3390 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf))
3272 (re-search-forward 3391 (re-search-forward
3273 ediff-regexp-hide-B 3392 regex-B
3274 (ediff-get-diff-posn 'B 'end n ctl-buf) 3393 (ediff-get-diff-posn 'B 'end n ctl-buf)
3275 t)))) 3394 t))))
3276 (and reg-A-match reg-B-match)))) 3395 (and reg-A-match reg-B-match))))
@@ -3338,6 +3457,7 @@ flags of the compared file buffers, kills Ediff buffers for this session
3338 (let ((buff-A ediff-A-buffer) 3457 (let ((buff-A ediff-A-buffer)
3339 (buff-B ediff-B-buffer)) 3458 (buff-B ediff-B-buffer))
3340 (ediff-kill-buffer-carefully ediff-diff-buffer) 3459 (ediff-kill-buffer-carefully ediff-diff-buffer)
3460 (ediff-kill-buffer-carefully ediff-fine-diff-buffer)
3341 (ediff-kill-buffer-carefully ediff-tmp-buffer) 3461 (ediff-kill-buffer-carefully ediff-tmp-buffer)
3342 (ediff-kill-buffer-carefully ediff-error-buffer) 3462 (ediff-kill-buffer-carefully ediff-error-buffer)
3343 (ediff-kill-buffer-carefully ediff-control-buffer) 3463 (ediff-kill-buffer-carefully ediff-control-buffer)
@@ -3367,11 +3487,13 @@ flags of the compared file buffers, kills Ediff buffers for this session
3367 (buf-patch ediff-patch-buf) 3487 (buf-patch ediff-patch-buf)
3368 (buf-patch-diag ediff-patch-diagnostics) 3488 (buf-patch-diag ediff-patch-diagnostics)
3369 (buf-err ediff-error-buffer) 3489 (buf-err ediff-error-buffer)
3370 (buf-diff ediff-diff-buffer)) 3490 (buf-diff ediff-diff-buffer)
3491 (buf-fine-diff ediff-fine-diff-buffer))
3371 (bury-buffer) ;; ediff-control-buffer 3492 (bury-buffer) ;; ediff-control-buffer
3372 (delete-other-windows) 3493 (delete-other-windows)
3373 (bury-buffer buf-err) 3494 (bury-buffer buf-err)
3374 (bury-buffer buf-diff) 3495 (bury-buffer buf-diff)
3496 (bury-buffer buf-fine-diff)
3375 (bury-buffer buf-patch) 3497 (bury-buffer buf-patch)
3376 (bury-buffer buf-patch-diag) 3498 (bury-buffer buf-patch-diag)
3377 (bury-buffer buf-A) 3499 (bury-buffer buf-A)
@@ -3415,23 +3537,32 @@ Hit \\[ediff-recenter] to reset the windows afterward."
3415 (princ (format "\nPoint position in buffer A = %d\n" A-line)) 3537 (princ (format "\nPoint position in buffer A = %d\n" A-line))
3416 (princ (format "Point position in buffer B = %d\n" B-line))) 3538 (princ (format "Point position in buffer B = %d\n" B-line)))
3417 3539
3418 (princ (format "\nCurrent difference number = %d\n" 3540 (princ (format "\nCurrent difference number = %S\n"
3419 (1+ ediff-current-difference))) 3541 (cond ((< ediff-current-difference 0) 'start)
3420 3542 ((>= ediff-current-difference
3543 ediff-number-of-differences) 'end)
3544 (t (1+ ediff-current-difference)))))
3545
3546 (cond (ediff-ignore-similar-regions
3547 (princ "\nSkipping over regions that differ only in white space & line breaks."))
3548 (t
3549 (princ "\nNo skipping over regions that differ in white space & line breaks.")))
3550
3421 (cond ((eq ediff-skip-diff-region-function 'ediff-show-all-diffs) 3551 (cond ((eq ediff-skip-diff-region-function 'ediff-show-all-diffs)
3422 (princ "\nSelective browsing is not in effect.\n")) 3552 (princ "\nSelective browsing by regexp is off.\n"))
3423 ((eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) 3553 ((eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches)
3424 (princ 3554 (princ
3425 "\nSelective browsing is in effect. Ignoring diff regions that:") 3555 "\nIgnoring regions that match")
3426 (princ 3556 (princ
3427 (format "\n match `%s' in buffer A and `%s' in buffer B\n" 3557 (format "\n\t regexp `%s' in buffer A and\n\t regexp `%s' in buffer B\n"
3428 ediff-regexp-hide-A ediff-regexp-hide-B))) 3558 ediff-regexp-hide-A ediff-regexp-hide-B)))
3429 ((eq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches) 3559 ((eq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches)
3430 (princ 3560 (princ
3431 "\nSelective browsing is in effect. Focus on diff regions that:") 3561 "\nFocusing on regions that match")
3432 (princ 3562 (princ
3433 (format "\n match `%s' in buffer A and `%s' in buffer B\n" 3563 (format "\n\t regexp `%s' in buffer A and\n\t regexp `%s' in buffer B\n"
3434 ediff-regexp-focus-A ediff-regexp-focus-B)))) 3564 ediff-regexp-focus-A ediff-regexp-focus-B)))
3565 (t (princ "\nSelective browsing via a user-defined method.\n")))
3435 3566
3436 (princ "\nBug fixes to: Michael Kifer <kifer@cs.sunysb.edu>\n") 3567 (princ "\nBug fixes to: Michael Kifer <kifer@cs.sunysb.edu>\n")
3437 (princ "Gripes to: /dev/null <dev@null.gov>\n") 3568 (princ "Gripes to: /dev/null <dev@null.gov>\n")
@@ -3459,20 +3590,19 @@ Hit \\[ediff-recenter] to reset the windows afterward."
3459 (ediff-place-flags-in-buffer 'B ediff-B-buffer 3590 (ediff-place-flags-in-buffer 'B ediff-B-buffer
3460 ediff-control-buffer n)) 3591 ediff-control-buffer n))
3461 3592
3462 (if window-system 3593 (cond ((eq ediff-auto-refine 'on)
3463 (cond ((eq ediff-auto-refine 'on) 3594 (if (and
3464 (if (and 3595 (> ediff-auto-refine-limit
3465 (> ediff-auto-refine-limit 3596 (- (ediff-get-diff-posn 'A 'end n)
3466 (- (ediff-get-diff-posn 'A 'end n) 3597 (ediff-get-diff-posn 'A 'beg n)))
3467 (ediff-get-diff-posn 'A 'beg n))) 3598 (> ediff-auto-refine-limit
3468 (> ediff-auto-refine-limit 3599 (- (ediff-get-diff-posn 'B 'end n)
3469 (- (ediff-get-diff-posn 'B 'end n) 3600 (ediff-get-diff-posn 'B 'beg n))))
3470 (ediff-get-diff-posn 'B 'beg n)))) 3601 (ediff-make-fine-diffs n 'noforce)
3471 (ediff-make-fine-diffs n 'noforce) 3602 (ediff-make-fine-diffs n 'skip)))
3472 (ediff-make-fine-diffs n 'skip))) 3603
3473 3604 ((eq ediff-auto-refine 'off) ; highlight iff fine diffs
3474 ((eq ediff-auto-refine 'off) ; highlight iff fine diffs 3605 (ediff-make-fine-diffs n 'skip))) ; already exist
3475 (ediff-make-fine-diffs n 'skip)))) ; already exist
3476 3606
3477 (ediff-restore-buffer-characteristics) 3607 (ediff-restore-buffer-characteristics)
3478 (run-hooks 'ediff-select-hooks)))) 3608 (run-hooks 'ediff-select-hooks))))
@@ -3502,9 +3632,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
3502 (setq ediff-highlighting-style nil) 3632 (setq ediff-highlighting-style nil)
3503 3633
3504 ;; unhighlight fine diffs 3634 ;; unhighlight fine diffs
3505 (if window-system 3635 (ediff-set-fine-diff-properties ediff-current-difference 'default)
3506 (ediff-set-fine-diff-properties
3507 ediff-current-difference 'default))
3508 3636
3509 (run-hooks 'ediff-unselect-hooks)))) 3637 (run-hooks 'ediff-unselect-hooks))))
3510 3638
@@ -3783,14 +3911,21 @@ them before they disappear."
3783 (setq ediff-disturbed-overlays nil)) 3911 (setq ediff-disturbed-overlays nil))
3784 3912
3785(defun ediff-save-buffer () 3913(defun ediff-save-buffer ()
3786 "Safe way of saving buffers A and B." 3914 "Safe way of saving buffers A, B, and the diff output.
3915`wa' saves buffer A, `wb' saves buffer B, and `wf' saves the diff output."
3787 (interactive) 3916 (interactive)
3788 (let ((hooks local-write-file-hooks)) 3917 (let ((hooks local-write-file-hooks))
3789 (ediff-unselect-and-select-difference ediff-current-difference 3918 (ediff-unselect-and-select-difference ediff-current-difference
3790 'unselect-only) 3919 'unselect-only)
3791 (unwind-protect 3920 (unwind-protect
3792 (ediff-eval-in-buffer 3921 (ediff-eval-in-buffer
3793 (if (eq last-command-char ?a) ediff-A-buffer ediff-B-buffer) 3922 (cond ((eq last-command-char ?a)
3923 ediff-A-buffer)
3924 ((eq last-command-char ?b)
3925 ediff-B-buffer)
3926 ((eq last-command-char ?f)
3927 (message "Saving diff output ...")(sit-for 1)
3928 ediff-diff-buffer))
3794 ;; temporarily remove writing block 3929 ;; temporarily remove writing block
3795 (setq hooks (delq 'ediff-block-write-file hooks)) 3930 (setq hooks (delq 'ediff-block-write-file hooks))
3796 (let ((local-write-file-hooks hooks)) 3931 (let ((local-write-file-hooks hooks))
@@ -3984,7 +4119,7 @@ buffer."
3984 (ediff-overlay-put (ediff-get-diff-overlay n 'A) 'face nil) 4119 (ediff-overlay-put (ediff-get-diff-overlay n 'A) 'face nil)
3985 (ediff-overlay-put (ediff-get-diff-overlay n 'B) 'face nil) 4120 (ediff-overlay-put (ediff-get-diff-overlay n 'B) 'face nil)
3986 4121
3987 (sit-for 0) ;; needs to synch for some reason 4122 ;; (sit-for 0) ;; needed synch for some reason in v19.22
3988 )) 4123 ))
3989 4124
3990 4125
@@ -4105,98 +4240,107 @@ This is the default for `ediff-forward-word-function'."
4105;; if `flag' is 'skip then don't compute fine diffs for this region. 4240;; if `flag' is 'skip then don't compute fine diffs for this region.
4106(defun ediff-make-fine-diffs (&optional n flag) 4241(defun ediff-make-fine-diffs (&optional n flag)
4107 (interactive) 4242 (interactive)
4108 (if (not window-system)
4109 (error "Non-window system."))
4110 (or n (setq n ediff-current-difference)) 4243 (or n (setq n ediff-current-difference))
4111 4244
4112 (if (< ediff-number-of-differences 1) 4245 (if (< ediff-number-of-differences 1)
4113 (error "No differences found.")) 4246 (error "No differences found."))
4114 4247
4115 (let ((file-A ediff-temp-file-A) 4248 (or (< n 0)
4249 (>= n ediff-number-of-differences)
4250 ;; n is within the range
4251 (let ((file-A ediff-temp-file-A)
4116 (file-B ediff-temp-file-B)) 4252 (file-B ediff-temp-file-B))
4117 4253
4118 (cond ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n)) 4254 (cond ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n))
4119 nil) 4255 nil)
4120 ((eq flag 'skip) 4256 ((eq flag 'skip)
4121 (or (ediff-get-fine-diff-vector n) 4257 (or (ediff-get-fine-diff-vector n)
4122 (eq ediff-auto-refine 'off) 4258 (eq ediff-auto-refine 'off)
4123 (message "Region %d is larger than auto-refine limit. Hit %S to force-refine." 4259 (message "Region %d is larger than auto-refine limit. Hit %S to force-refine."
4124 (1+ n) 4260 (1+ n)
4125 (substitute-command-keys "\\[ediff-make-fine-diffs]") 4261 (substitute-command-keys
4126 ))) 4262 "\\[ediff-make-fine-diffs]")
4127 (t 4263 )))
4128 ;; delete old fine diffs 4264 (t
4129 (ediff-clear-diff-vector (ediff-get-fine-diff-vector n)) 4265 ;; delete old fine diffs
4130 ;; recompute fine diffs 4266 (ediff-clear-diff-vector (ediff-get-fine-diff-vector n))
4131 (setq ediff-tmp-buffer (get-buffer-create "*ediff-tmp*")) 4267 ;; recompute fine diffs
4132 4268 (setq ediff-tmp-buffer (get-buffer-create "*ediff-tmp*"))
4133 (ediff-wordify 4269
4134 (ediff-get-diff-posn 'A 'beg n) 4270 (ediff-wordify
4135 (ediff-get-diff-posn 'A 'end n) 4271 (ediff-get-diff-posn 'A 'beg n)
4136 ediff-A-buffer 4272 (ediff-get-diff-posn 'A 'end n)
4137 ediff-tmp-buffer) 4273 ediff-A-buffer
4138 (ediff-eval-in-buffer 4274 ediff-tmp-buffer)
4139 ediff-tmp-buffer 4275 (ediff-eval-in-buffer
4140 (setq file-A (ediff-make-temp-file ".fine-diffs-A" file-A))) 4276 ediff-tmp-buffer
4141 4277 (setq file-A (ediff-make-temp-file ".fine-diffs-A" file-A)))
4142 (ediff-wordify 4278
4143 (ediff-get-diff-posn 'B 'beg n) 4279 (ediff-wordify
4144 (ediff-get-diff-posn 'B 'end n) 4280 (ediff-get-diff-posn 'B 'beg n)
4145 ediff-B-buffer 4281 (ediff-get-diff-posn 'B 'end n)
4146 ediff-tmp-buffer) 4282 ediff-B-buffer
4147 (ediff-eval-in-buffer 4283 ediff-tmp-buffer)
4148 ediff-tmp-buffer 4284 (ediff-eval-in-buffer
4149 (setq file-B (ediff-make-temp-file ".fine-diffs-B" file-B))) 4285 ediff-tmp-buffer
4150 4286 (setq file-B (ediff-make-temp-file ".fine-diffs-B" file-B)))
4151 ;; save temp file names. 4287
4152 (setq ediff-temp-file-A file-A 4288 ;; save temp file names.
4153 ediff-temp-file-B file-B) 4289 (setq ediff-temp-file-A file-A
4154 4290 ediff-temp-file-B file-B)
4155 ;; set the new vector of fine diffs, if none exists 4291
4156 (ediff-set-fine-diff-vector 4292 ;; set the new vector of fine diffs, if none exists
4157 n 4293 (ediff-set-fine-diff-vector
4158 (ediff-setup-diff-regions file-A file-B 'use-old-diff-buf n 4294 n
4159 ediff-fine-diff-program 4295 (ediff-setup-diff-regions file-A file-B 'use-old-diff-buf n
4160 ediff-fine-diff-options 4296 ediff-fine-diff-program
4161 ediff-fine-diff-ok-lines-regexp)) 4297 ediff-fine-diff-options
4162 (if (eq (length (ediff-get-fine-diff-vector n)) 0) 4298 ediff-fine-diff-ok-lines-regexp))
4163 (message "No differences found in region %d, except for white space and line breaks." 4299 (if (eq (length (ediff-get-fine-diff-vector n)) 0)
4164 (1+ n)))) 4300 (progn
4165 ) ;; end cond 4301 (message "No diffs found in region %d, except for white space and line breaks."
4166 (ediff-set-fine-diff-properties n) 4302 (1+ n))
4167 )) 4303 (ediff-mark-diff-as-space-only n t))
4304 (ediff-mark-diff-as-space-only n nil)))
4305 ) ;; end cond
4306 (ediff-set-fine-diff-properties n)
4307 )))
4168 4308
4169 4309
4170(defun ediff-set-fine-diff-properties (n &optional default) 4310(defun ediff-set-fine-diff-properties (n &optional default)
4171 (let ((fine-diff-vector (ediff-get-fine-diff-vector n)) 4311 (or (not window-system)
4172 (face-A (if default 'default (face-name ediff-fine-diff-face-A))) 4312 (< n 0)
4173 (face-B (if default 'default (face-name ediff-fine-diff-face-B))) 4313 (>= n ediff-number-of-differences)
4174 (priority-A (if default 4314 ;; in a window system, set faces and priorities of fine overlays
4175 0 4315 (let ((fine-diff-vector (ediff-get-fine-diff-vector n))
4176 (1+ (ediff-overlay-get ediff-current-diff-overlay-A 4316 (face-A (if default 'default (face-name ediff-fine-diff-face-A)))
4177 'priority)))) 4317 (face-B (if default 'default (face-name ediff-fine-diff-face-B)))
4178 (priority-B (if default 4318 (priority-A (if default
4179 0 4319 0
4180 (1+ (ediff-overlay-get ediff-current-diff-overlay-B 4320 (1+ (ediff-overlay-get ediff-current-diff-overlay-A
4181 'priority))))) 4321 'priority))))
4182 (mapcar 4322 (priority-B (if default
4183 (function (lambda (vec) 4323 0
4184 (ediff-overlay-put 4324 (1+ (ediff-overlay-get ediff-current-diff-overlay-B
4185 (ediff-get-diff-overlay-from-vector vec 'A) 4325 'priority)))))
4186 'face face-A) 4326 (mapcar
4187 (ediff-overlay-put 4327 (function (lambda (vec)
4188 (ediff-get-diff-overlay-from-vector vec 'A) 4328 (ediff-overlay-put
4189 'priority priority-A) 4329 (ediff-get-diff-overlay-from-vector vec 'A)
4190 4330 'face face-A)
4191 (ediff-overlay-put 4331 (ediff-overlay-put
4192 (ediff-get-diff-overlay-from-vector vec 'B) 4332 (ediff-get-diff-overlay-from-vector vec 'A)
4193 'face face-B) 4333 'priority priority-A)
4194 (ediff-overlay-put 4334
4195 (ediff-get-diff-overlay-from-vector vec 'B) 4335 (ediff-overlay-put
4196 'priority priority-B) 4336 (ediff-get-diff-overlay-from-vector vec 'B)
4197 )) 4337 'face face-B)
4198 fine-diff-vector) 4338 (ediff-overlay-put
4199 )) 4339 (ediff-get-diff-overlay-from-vector vec 'B)
4340 'priority priority-B)
4341 ))
4342 fine-diff-vector)
4343 )))
4200 4344
4201(defun ediff-convert-diffs-to-overlays-refine (A-buffer B-buffer 4345(defun ediff-convert-diffs-to-overlays-refine (A-buffer B-buffer
4202 diff-list refine-region) 4346 diff-list refine-region)
@@ -4218,7 +4362,7 @@ This is the default for `ediff-forward-word-function'."
4218 b-begin (aref list-element 2) 4362 b-begin (aref list-element 2)
4219 b-end (aref list-element 3)) 4363 b-end (aref list-element 3))
4220 4364
4221 ;; place overlays at the appropriate places in the buffers 4365 ;; put overlays at appropriate places in buffers
4222 (setq a-overlay (ediff-make-overlay 4366 (setq a-overlay (ediff-make-overlay
4223 (ediff-goto-word (1+ a-begin) A-buffer) 4367 (ediff-goto-word (1+ a-begin) A-buffer)
4224 (ediff-goto-word a-end A-buffer 'end) 4368 (ediff-goto-word a-end A-buffer 'end)