bug-gnu-emacs
[Top][All Lists]
Advanced

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

ediff-diff changes


From: Dave Love
Subject: ediff-diff changes
Date: 03 Jan 2002 11:41:10 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.30

Currently, refining diffs conses like crazy and is basically unusable
on a P100.  I'm surprised this didn't bother others and get fixed.
This patch against Emacs 21.1 makes it usable again, inter alia
(mainly due to the change in `ediff-goto-word' I think).  I should
have got this fixed for 21.1 and I think at least that part that
should go in 21.2.

In the rest, I changed `ediff-word-1' to cover non-ASCII characters (I
don't know if that will work in XEmacs), and to follow the manual re
including `-' in a set, since it's not obvious what `---' will do.
The copy-to-buffer change probably isn't important.

2002-01-02  Dave Love  <fx@gnu.org>

        * ediff-diff.el: Doc fixes.
        (ediff-word-1): Use word class and move - to the
        front per regexp documentation.
        (ediff-wordify): Bind forward-word-function outside loop.
        (ediff-copy-to-buffer): Use insert-buffer-substring rather than
        consing buffer contents.
        (ediff-goto-word): Move syntax table setting outside loop.

Index: ediff-diff.el
===================================================================
RCS file: /cvs/emacs/lisp/ediff-diff.el,v
retrieving revision 1.31
diff -u -p -c -r1.31 ediff-diff.el
cvs server: conflicting specifications of output style
*** ediff-diff.el       21 Jul 2001 05:28:24 -0000      1.31
--- ediff-diff.el       2 Jan 2002 23:01:38 -0000
***************
*** 1,6 ****
  ;;; ediff-diff.el --- diff-related utilities
  
! ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
  
  ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
  
--- 1,6 ----
  ;;; ediff-diff.el --- diff-related utilities
  
! ;; Copyright (C) 1994, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
  
  ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
  
*************** Must produce output compatible with Unix
*** 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)))
--- 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)))
*************** Must produce output compatible with Unix
*** 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)
  
--- 102,113 ----
         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)
  
*************** It must return code 0, if its arguments 
*** 117,130 ****
    :group 'ediff-diff)
  
  (defcustom ediff-cmp-options nil
!   "*Options to pass to `ediff-cmp-program'.  If GNUS diff is used as
! `ediff-cmp-program', then the most useful options are `-I' RE, to
! ignore changes whose lines all match 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."
--- 118,131 ----
    :group 'ediff-diff)
  
  (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 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."
*************** This output is not used by Ediff interna
*** 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
--- 147,153 ----
  
  (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
*************** Lines that do not match are assumed to b
*** 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.
--- 164,170 ----
  (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.
*************** Use `setq-default' if setting it in .ema
*** 183,189 ****
    
  ;;; General
  
! (defvar ediff-diff-ok-lines-regexp  
    (concat
     "^\\("
     "[0-9,]+[acd][0-9,]+\C-m?$"
--- 184,190 ----
    
  ;;; General
  
! (defvar ediff-diff-ok-lines-regexp
    (concat
     "^\\("
     "[0-9,]+[acd][0-9,]+\C-m?$"
*************** one optional arguments, diff-number to r
*** 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.
--- 349,355 ----
        (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.
*************** one optional arguments, diff-number to r
*** 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))))
      
--- 375,381 ----
        (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))))
      
*************** one optional arguments, diff-number to r
*** 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)
--- 431,437 ----
         ;; 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)
*************** one optional arguments, diff-number to r
*** 474,480 ****
                 (forward-line (- c-end c-begin))
                 (setq c-end-pt (point)
                       c-prev c-end)))
!          (setq diff-list 
                 (nconc
                  diff-list
                  (list
--- 475,481 ----
                 (forward-line (- c-end c-begin))
                 (setq c-end-pt (point)
                       c-prev c-end)))
!          (setq diff-list
                 (nconc
                  diff-list
                  (list
*************** one optional arguments, diff-number to r
*** 495,501 ****
                             nil nil    ; dummy ancestor
                             nil nil    ; dummy state of diff & merge
                             nil        ; dummy state of ancestor
!                            ))) 
                  )))
                  
         ))) ; end ediff-with-current-buffer
--- 496,502 ----
                             nil nil    ; dummy ancestor
                             nil nil    ; dummy state of diff & merge
                             nil        ; dummy state of ancestor
!                            )))
                  )))
                  
         ))) ; end ediff-with-current-buffer
*************** one optional arguments, diff-number to r
*** 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)
--- 539,545 ----
                 (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)
*************** one optional arguments, diff-number to r
*** 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)
--- 616,622 ----
  ;; 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)
*************** one optional arguments, diff-number to r
*** 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)))
--- 652,664 ----
               (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)))
*************** one optional arguments, diff-number to r
*** 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
--- 773,779 ----
                                           "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
*************** one optional arguments, diff-number to r
*** 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
--- 813,819 ----
  (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
*************** delimiter regions"))
*** 896,902 ****
        ) ; 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))
        )))
  
--- 897,903 ----
        ) ; 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))
        )))
  
*************** delimiter regions"))
*** 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)))))
--- 959,968 ----
        (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)))))
*************** delimiter regions"))
*** 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)
--- 1027,1033 ----
               ;; 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)
*************** delimiter regions"))
*** 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
--- 1067,1073 ----
                       (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
*************** delimiter regions"))
*** 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.
--- 1201,1207 ----
          (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.
*************** Used for splitting difference regions in
*** 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.
--- 1211,1220 ----
    "*Characters constituting white space.
  These characters are ignored when differing regions are split into words.")
  
! (defvar ediff-word-1 "-[: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.
*************** See `ediff-forward-word' for more detail
*** 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.
--- 1230,1236 ----
    (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.
*************** arguments to `skip-chars-forward'."
*** 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
--- 1250,1263 ----
  
  
  (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
*************** arguments to `skip-chars-forward'."
*** 1271,1283 ****
       (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))
--- 1279,1285 ----
       (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))
*************** arguments to `skip-chars-forward'."
*** 1285,1299 ****
         
  ;; 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'
--- 1287,1296 ----
         
  ;; copy string from 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'
*************** arguments to `skip-chars-forward'."
*** 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))))
--- 1302,1319 ----
        (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]