emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/ediff-diff.el


From: Michael Kifer
Subject: [Emacs-diffs] Changes to emacs/lisp/ediff-diff.el
Date: Mon, 07 Jan 2002 23:36:02 -0500

Index: emacs/lisp/ediff-diff.el
diff -c emacs/lisp/ediff-diff.el:1.33 emacs/lisp/ediff-diff.el:1.34
*** emacs/lisp/ediff-diff.el:1.33       Tue Dec 11 01:04:14 2001
--- emacs/lisp/ediff-diff.el    Mon Jan  7 23:36:01 2002
***************
*** 1,8 ****
  ;;; ediff-diff.el --- diff-related utilities
  
! ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
  
! ;; Author: Michael Kifer <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
--- 1,8 ----
  ;;; ediff-diff.el --- diff-related utilities
  
! ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software 
Foundation, Inc.
  
! ;; Author: Michael Kifer <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
***************
*** 29,34 ****
--- 29,35 ----
  
  ;; compiler pacifier
  (defvar ediff-default-variant)
+ (defvar null-device)
  
  (eval-when-compile
    (let ((load-path (cons (expand-file-name ".") load-path)))
***************
*** 83,95 ****
  ;; make sure that mandatory options are added even if the user changes
  ;; ediff-diff-options or ediff-diff3-options in the customization widget
  (defun ediff-reset-diff-options (symb val)
!   (let* ((diff-program 
!         (if (eq symb 'ediff-diff-options) 
              ediff-diff-program
            ediff-diff3-program))
         (mandatory-option (ediff-diff-mandatory-option diff-program))
         (spacer (if (string-equal mandatory-option "") "" " ")))
!     (set symb 
         (if (string-match mandatory-option val)
             val
           (concat mandatory-option spacer val)))
--- 84,96 ----
  ;; make sure that mandatory options are added even if the user changes
  ;; ediff-diff-options or ediff-diff3-options in the customization widget
  (defun ediff-reset-diff-options (symb val)
!   (let* ((diff-program
!         (if (eq symb 'ediff-diff-options)
              ediff-diff-program
            ediff-diff3-program))
         (mandatory-option (ediff-diff-mandatory-option diff-program))
         (spacer (if (string-equal mandatory-option "") "" " ")))
!     (set symb
         (if (string-match mandatory-option val)
             val
           (concat mandatory-option spacer val)))
***************
*** 102,112 ****
         shell-file-name) ; no standard name on MS-DOS
        ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS
        (t  "sh")) ; UNIX
!   "*The shell used to run diff and patch.  If user's .profile or
! .cshrc files are set up correctly, any shell will do.  However, some people
! set $prompt or other things incorrectly, which leads to undesirable output
! messages.  These may cause Ediff to fail.  In such a case, set ediff-shell
! to a shell that you are not using or, better, fix your shell's startup file."
    :type 'string
    :group 'ediff-diff)
  
--- 103,114 ----
         shell-file-name) ; no standard name on MS-DOS
        ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS
        (t  "sh")) ; UNIX
!   "*The shell used to run diff and patch.
! If user's .profile or .cshrc files are set up correctly, any shell
! will do.  However, some people set $prompt or other things
! incorrectly, which leads to undesirable output messages.  These may
! cause Ediff to fail.  In such a case, set `ediff-shell' to a shell that
! you are not using or, better, fix your shell's startup file."
    :type 'string
    :group 'ediff-diff)
  
***************
*** 119,131 ****
  (defcustom ediff-cmp-options nil
    "*Options to pass to `ediff-cmp-program'.
  If GNU diff is used as `ediff-cmp-program', then the most useful options
! are `-I RE', to ignore changes whose lines all match the regexp RE."
    :type '(repeat string)
    :group 'ediff-diff)
  
  (defcustom ediff-diff-options ""
    "*Options to pass to `ediff-diff-program'. 
! If diff\(1\) is used as `ediff-diff-program', then the most useful options are
  `-w', to ignore space, and `-i', to ignore case of letters.
  At present, the option `-c' is not allowed."
    :set 'ediff-reset-diff-options
--- 121,133 ----
  (defcustom ediff-cmp-options nil
    "*Options to pass to `ediff-cmp-program'.
  If GNU diff is used as `ediff-cmp-program', then the most useful options
! are `-I REGEXP', to ignore changes whose lines match the REGEXP."
    :type '(repeat string)
    :group 'ediff-diff)
  
  (defcustom ediff-diff-options ""
    "*Options to pass to `ediff-diff-program'. 
! If Unix diff is used as `ediff-diff-program', then the most useful options are
  `-w', to ignore space, and `-i', to ignore case of letters.
  At present, the option `-c' is not allowed."
    :set 'ediff-reset-diff-options
***************
*** 146,152 ****
  
  (defvar ediff-match-diff3-line "^====\\(.?\\)\C-m?$"
    "Pattern to match lines produced by diff3 that describe differences.")
! (defcustom ediff-diff3-options ""  
    "*Options to pass to `ediff-diff3-program'."
    :set 'ediff-reset-diff-options
    :type 'string
--- 148,154 ----
  
  (defvar ediff-match-diff3-line "^====\\(.?\\)\C-m?$"
    "Pattern to match lines produced by diff3 that describe differences.")
! (defcustom ediff-diff3-options ""
    "*Options to pass to `ediff-diff3-program'."
    :set 'ediff-reset-diff-options
    :type 'string
***************
*** 163,169 ****
  (ediff-defvar-local ediff-diff-status "" "")
  
    
! ;;; Fine differences 
  
  (ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix)
    "If `on', Ediff auto-highlights fine diffs for the current diff region.
--- 165,171 ----
  (ediff-defvar-local ediff-diff-status "" "")
  
    
! ;;; Fine differences
  
  (ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix)
    "If `on', Ediff auto-highlights fine diffs for the current diff region.
***************
*** 183,189 ****
    
  ;;; General
  
! (defvar ediff-diff-ok-lines-regexp  
    (concat
     "^\\("
     "[0-9,]+[acd][0-9,]+\C-m?$"
--- 185,191 ----
    
  ;;; General
  
! (defvar ediff-diff-ok-lines-regexp
    (concat
     "^\\("
     "[0-9,]+[acd][0-9,]+\C-m?$"
***************
*** 348,354 ****
        (ediff-skip-unsuitable-frames)
        (switch-to-buffer error-buf)
        (ediff-kill-buffer-carefully ctl-buf)
!       (error "Errors in diff output. Diff output is in %S" diff-buff))))
  
  ;; BOUNDS specifies visibility bounds to use.
  ;; WORD-MODE tells whether we are in the word-mode or not.
--- 350,356 ----
        (ediff-skip-unsuitable-frames)
        (switch-to-buffer error-buf)
        (ediff-kill-buffer-carefully ctl-buf)
!       (error "Errors in diff output.  Diff output is in %S" diff-buff))))
  
  ;; BOUNDS specifies visibility bounds to use.
  ;; WORD-MODE tells whether we are in the word-mode or not.
***************
*** 374,380 ****
        (setq shift-A
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'A bounds))
!             shift-B 
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'B bounds))))
      
--- 376,382 ----
        (setq shift-A
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'A bounds))
!             shift-B
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'B bounds))))
      
***************
*** 430,436 ****
         ;; compute main diff vector
         (if word-mode
             ;; make diff-list contain word numbers
!            (setq diff-list 
                   (nconc diff-list
                          (list
                           (if (ediff-buffer-live-p C-buffer)
--- 432,438 ----
         ;; compute main diff vector
         (if word-mode
             ;; make diff-list contain word numbers
!            (setq diff-list
                   (nconc diff-list
                          (list
                           (if (ediff-buffer-live-p C-buffer)
***************
*** 474,480 ****
                 (forward-line (- c-end c-begin))
                 (setq c-end-pt (point)
                       c-prev c-end)))
!          (setq diff-list 
                 (nconc
                  diff-list
                  (list
--- 476,482 ----
                 (forward-line (- c-end c-begin))
                 (setq c-end-pt (point)
                       c-prev c-end)))
!          (setq diff-list
                 (nconc
                  diff-list
                  (list
***************
*** 495,501 ****
                             nil nil    ; dummy ancestor
                             nil nil    ; dummy state of diff & merge
                             nil        ; dummy state of ancestor
!                            ))) 
                  )))
                  
         ))) ; end ediff-with-current-buffer
--- 497,503 ----
                             nil nil    ; dummy ancestor
                             nil nil    ; dummy state of diff & merge
                             nil        ; dummy state of ancestor
!                            )))
                  )))
                  
         ))) ; end ediff-with-current-buffer
***************
*** 538,544 ****
                 (ediff-get-value-according-to-buffer-type
                  buf-type ediff-narrow-bounds)))
         (limit (ediff-overlay-end
!                (ediff-get-value-according-to-buffer-type 
                  buf-type ediff-narrow-bounds)))
         diff-overlay-list list-element total-diffs
         begin end pt-saved overlay state-of-diff)
--- 540,546 ----
                 (ediff-get-value-according-to-buffer-type
                  buf-type ediff-narrow-bounds)))
         (limit (ediff-overlay-end
!                (ediff-get-value-according-to-buffer-type
                  buf-type ediff-narrow-bounds)))
         diff-overlay-list list-element total-diffs
         begin end pt-saved overlay state-of-diff)
***************
*** 615,621 ****
  ;; if `flag' is 'noforce then make fine-diffs only if this region's fine
  ;; diffs have not been computed before.
  ;; if `flag' is 'skip then don't compute fine diffs for this region.
! (defun ediff-make-fine-diffs (&optional n flag)       
    (or n  (setq n ediff-current-difference))
    
    (if (< ediff-number-of-differences 1)
--- 617,623 ----
  ;; if `flag' is 'noforce then make fine-diffs only if this region's fine
  ;; diffs have not been computed before.
  ;; if `flag' is 'skip then don't compute fine diffs for this region.
! (defun ediff-make-fine-diffs (&optional n flag)
    (or n  (setq n ediff-current-difference))
    
    (if (< ediff-number-of-differences 1)
***************
*** 651,663 ****
               (if ediff-3way-comparison-job
                   (ediff-message-if-verbose
                    "Region %d is empty in all buffers but %S"
!                   (1+ n) 
                    (cond ((not empty-A) 'A)
                          ((not empty-B) 'B)
                          ((not empty-C) 'C)))
                 (ediff-message-if-verbose
                  "Region %d in buffer %S is empty"
!                 (1+ n) 
                  (cond (empty-A 'A)
                        (empty-B 'B)
                        (empty-C 'C)))
--- 653,665 ----
               (if ediff-3way-comparison-job
                   (ediff-message-if-verbose
                    "Region %d is empty in all buffers but %S"
!                   (1+ n)
                    (cond ((not empty-A) 'A)
                          ((not empty-B) 'B)
                          ((not empty-C) 'C)))
                 (ediff-message-if-verbose
                  "Region %d in buffer %S is empty"
!                 (1+ n)
                  (cond (empty-A 'A)
                        (empty-B 'B)
                        (empty-C 'C)))
***************
*** 772,778 ****
                                           "in buffers A & C")
                             (whitespace-C (ediff-mark-diff-as-space-only n 'C)
                                           "in buffers A & B"))))
!                    (t 
                      (ediff-mark-diff-as-space-only n nil)))
               )
              ) ; end cond
--- 774,780 ----
                                           "in buffers A & C")
                             (whitespace-C (ediff-mark-diff-as-space-only n 'C)
                                           "in buffers A & B"))))
!                    (t
                      (ediff-mark-diff-as-space-only n nil)))
               )
              ) ; end cond
***************
*** 812,818 ****
  (defun ediff-set-fine-diff-properties-in-one-buffer (buf-type
                                                     n &optional default)
    (let ((fine-diff-vector  (ediff-get-fine-diff-vector n buf-type))
!       (face (if default 
                  'default
                (face-name
                 (ediff-get-symbol-from-alist
--- 814,820 ----
  (defun ediff-set-fine-diff-properties-in-one-buffer (buf-type
                                                     n &optional default)
    (let ((fine-diff-vector  (ediff-get-fine-diff-vector n buf-type))
!       (face (if default
                  'default
                (face-name
                 (ediff-get-symbol-from-alist
***************
*** 896,906 ****
        ) ; while
        ;; convert the list of difference information into a vector
        ;; for fast access
!       (ediff-set-fine-diff-vector 
         region-num buf-type (vconcat diff-overlay-list))
        )))
  
  
  ;; Stolen from emerge.el
  (defun ediff-get-diff3-group (file)
    ;; This save-excursion allows ediff-get-diff3-group to be called for the
--- 898,916 ----
        ) ; while
        ;; convert the list of difference information into a vector
        ;; for fast access
!       (ediff-set-fine-diff-vector
         region-num buf-type (vconcat diff-overlay-list))
        )))
  
  
+ (defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num)
+   (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num)
+   (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num)
+   (if ediff-3way-job
+       (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num)
+     ))
+ 
+ 
  ;; Stolen from emerge.el
  (defun ediff-get-diff3-group (file)
    ;; This save-excursion allows ediff-get-diff3-group to be called for the
***************
*** 958,967 ****
        (setq shift-A
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'A bounds))
!             shift-B 
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'B bounds))
!             shift-C 
              (if three-way-comp
                  (ediff-overlay-start
                   (ediff-get-value-according-to-buffer-type 'C bounds)))))
--- 968,977 ----
        (setq shift-A
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'A bounds))
!             shift-B
              (ediff-overlay-start
               (ediff-get-value-according-to-buffer-type 'B bounds))
!             shift-C
              (if three-way-comp
                  (ediff-overlay-start
                   (ediff-get-value-according-to-buffer-type 'C bounds)))))
***************
*** 1026,1032 ****
               ;; compute main diff vector
               (if word-mode
                   ;; make diff-list contain word numbers
!                  (setq diff-list 
                         (nconc diff-list
                                (list (vector
                                       (- a-begin a-prev) (- a-end a-begin)
--- 1036,1042 ----
               ;; compute main diff vector
               (if word-mode
                   ;; make diff-list contain word numbers
!                  (setq diff-list
                         (nconc diff-list
                                (list (vector
                                       (- a-begin a-prev) (- a-end a-begin)
***************
*** 1066,1072 ****
                       (forward-line (- c-or-anc-end c-or-anc-begin))
                       (setq anc-end-pt (point)
                             anc-prev c-or-anc-end)))
!                (setq diff-list 
                       (nconc
                        diff-list
                        ;; if comparing with ancestor, then there also is a
--- 1076,1082 ----
                       (forward-line (- c-or-anc-end c-or-anc-begin))
                       (setq anc-end-pt (point)
                             anc-prev c-or-anc-end)))
!                (setq diff-list
                       (nconc
                        diff-list
                        ;; if comparing with ancestor, then there also is a
***************
*** 1200,1206 ****
          (delete-process process))))
        
  
! ;;; Word functions used to refine the current diff        
  
  (defvar ediff-forward-word-function 'ediff-forward-word
    "*Function to call to move to the next word.
--- 1210,1216 ----
          (delete-process process))))
        
  
! ;;; Word functions used to refine the current diff
  
  (defvar ediff-forward-word-function 'ediff-forward-word
    "*Function to call to move to the next word.
***************
*** 1210,1219 ****
    "*Characters constituting white space.
  These characters are ignored when differing regions are split into words.")
  
! (defvar ediff-word-1 "a-zA-Z---_"
    "*Characters that constitute words of type 1.
  More precisely, [ediff-word-1] is a regexp that matches type 1 words.
! See `ediff-forward-word' for more details.")  
  
  (defvar ediff-word-2 "0-9.,"
    "*Characters that constitute words of type 2.
--- 1220,1230 ----
    "*Characters constituting white space.
  These characters are ignored when differing regions are split into words.")
  
! (defvar ediff-word-1
!   (ediff-cond-compile-for-xemacs-or-emacs "a-zA-Z---_" "-[:word:]_")
    "*Characters that constitute words of type 1.
  More precisely, [ediff-word-1] is a regexp that matches type 1 words.
! See `ediff-forward-word' for more details.")
  
  (defvar ediff-word-2 "0-9.,"
    "*Characters that constitute words of type 2.
***************
*** 1229,1235 ****
    (concat "^" ediff-word-1 ediff-word-2 ediff-word-3 ediff-whitespace)
    "*Characters that constitute words of type 4.
  More precisely, [ediff-word-4] is a regexp that matches type 4 words.
! See `ediff-forward-word' for more details.")  
  
  ;; Split region along word boundaries. Each word will be on its own line.
  ;; Output to buffer out-buffer.
--- 1240,1246 ----
    (concat "^" ediff-word-1 ediff-word-2 ediff-word-3 ediff-whitespace)
    "*Characters that constitute words of type 4.
  More precisely, [ediff-word-4] is a regexp that matches type 4 words.
! See `ediff-forward-word' for more details.")
  
  ;; Split region along word boundaries. Each word will be on its own line.
  ;; Output to buffer out-buffer.
***************
*** 1249,1255 ****
  
  
  (defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf)
!   (let (inbuf-syntax-tbl sv-point diff-string)
      (save-excursion
       (set-buffer in-buffer)
       (setq inbuf-syntax-tbl
--- 1260,1273 ----
  
  
  (defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf)
!   (let ((forward-word-function
!        ;; eval in control buf to let user create local versions for
!        ;; different invocations
!        (if control-buf
!            (ediff-with-current-buffer control-buf
!              ediff-forward-word-function)
!          ediff-forward-word-function))
!       inbuf-syntax-tbl sv-point diff-string)
      (save-excursion
       (set-buffer in-buffer)
       (setq inbuf-syntax-tbl
***************
*** 1271,1299 ****
       (delete-region (point-min) (point))
       
       (while (not (eobp))
!        ;; eval in control buf to let user create local versions for
!        ;; different invocations
!        (if control-buf
!          (funcall 
!           (ediff-with-current-buffer control-buf
!             ediff-forward-word-function))
!        (funcall ediff-forward-word-function))
         (setq sv-point (point))
         (skip-chars-forward ediff-whitespace)
         (delete-region sv-point (point))
         (insert "\n")))))
         
! ;; copy string from BEG END from IN-BUF to OUT-BUF
  (defun ediff-copy-to-buffer (beg end in-buffer out-buffer)
!   (let (string)
!     (save-excursion
!       (set-buffer in-buffer)
!      (setq string (buffer-substring beg end))
! 
!      (set-buffer out-buffer)
!      (erase-buffer)
!      (insert string)
!      (goto-char (point-min)))))
  
  
  ;; goto word #n starting at current position in buffer `buf'
--- 1289,1306 ----
       (delete-region (point-min) (point))
       
       (while (not (eobp))
!        (funcall forward-word-function)
         (setq sv-point (point))
         (skip-chars-forward ediff-whitespace)
         (delete-region sv-point (point))
         (insert "\n")))))
         
! ;; copy string specified as BEG END from IN-BUF to OUT-BUF
  (defun ediff-copy-to-buffer (beg end in-buffer out-buffer)
!   (with-current-buffer out-buffer
!     (erase-buffer)
!     (insert-buffer-substring in-buffer beg end)
!     (goto-char (point-min))))
  
  
  ;; goto word #n starting at current position in buffer `buf'
***************
*** 1305,1322 ****
        (syntax-tbl ediff-syntax-table))
      (ediff-with-current-buffer buf
        (skip-chars-forward ediff-whitespace)
!       (while (> n 1)
!       (ediff-with-syntax-table syntax-tbl
!           (funcall fwd-word-fun))
!       (skip-chars-forward ediff-whitespace)
!       (setq n (1- n)))
        (if (and flag (> n 0))
          (funcall fwd-word-fun))
        (point))))
  
  (defun ediff-same-file-contents (f1 f2)
!   "T if F1 and F2 have identical contents."
!   (let ((res 
         (apply 'call-process ediff-cmp-program nil nil nil
                (append ediff-cmp-options (list f1 f2)))))
      (and (numberp res) (eq res 0))))
--- 1312,1329 ----
        (syntax-tbl ediff-syntax-table))
      (ediff-with-current-buffer buf
        (skip-chars-forward ediff-whitespace)
!       (ediff-with-syntax-table syntax-tbl
!       (while (> n 1)
!         (funcall fwd-word-fun)
!         (skip-chars-forward ediff-whitespace)
!         (setq n (1- n))))
        (if (and flag (> n 0))
          (funcall fwd-word-fun))
        (point))))
  
  (defun ediff-same-file-contents (f1 f2)
!   "Return t if F1 and F2 have identical contents."
!   (let ((res
         (apply 'call-process ediff-cmp-program nil nil nil
                (append ediff-cmp-options (list f1 f2)))))
      (and (numberp res) (eq res 0))))



reply via email to

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