unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* ediff-regions-internal can't handle (non-overlapping) regions in the same buffer
@ 2005-12-07 20:59 Kevin Rodgers
  2005-12-09 16:47 ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2005-12-07 20:59 UTC (permalink / raw)


I'm working on a way to take advantage of Ediff's fine highlighting
feature within Diff mode buffers.  But calling ediff-regions-internal
programmatically with BUFFER-A the same as BUFFER-B doesn't work,
leaving only the region between BEG-B and END-B highighted.  This is
because ediff-extract-diffs first resets point in both buffers (changing
point in BUFFER-A unintentionally), then builds the diff vector by
moving by lines in each buffer.

The fix is simple, and it allows ediff-regions-internal to work with
non-overlapping regions in the same buffer: Don't set point in each
buffer until necessary:

*** emacs-21.4/lisp/ediff-diff.el~	Wed Jul  3 10:49:40 2002
--- emacs-21.4/lisp/ediff-diff.el	Wed Dec  7 13:34:26 2005
***************
*** 378,388 ****
   	      (ediff-overlay-start
   	       (ediff-get-value-according-to-buffer-type 'B bounds))))

!     ;; reset point in buffers A/B/C
!     (ediff-with-current-buffer A-buffer
!       (goto-char (if shift-A shift-A (point-min))))
!     (ediff-with-current-buffer B-buffer
!       (goto-char (if shift-B shift-B (point-min))))
       (if (ediff-buffer-live-p C-buffer)
   	(ediff-with-current-buffer C-buffer
   	  (goto-char (point-min))))
--- 378,384 ----
   	      (ediff-overlay-start
   	       (ediff-get-value-according-to-buffer-type 'B bounds))))

!     ;; reset point in buffer C
       (if (ediff-buffer-live-p C-buffer)
   	(ediff-with-current-buffer C-buffer
   	  (goto-char (point-min))))
***************
*** 456,461 ****
--- 452,458 ----
   		   c-prev c-end)
   	   ;; else convert lines to points
   	   (ediff-with-current-buffer A-buffer
+              (goto-char (if shift-A shift-A (point-min)))
   	     (forward-line (- a-begin a-prev))
   	     (setq a-begin-pt (point))
   	     (forward-line (- a-end a-begin))
***************
*** 462,467 ****
--- 459,465 ----
   	     (setq a-end-pt (point)
   		   a-prev a-end))
   	   (ediff-with-current-buffer B-buffer
+              (goto-char (if shift-B shift-B (point-min)))
   	     (forward-line (- b-begin b-prev))
   	     (setq b-begin-pt (point))
   	     (forward-line (- b-end b-begin))

Thanks,
-- 
Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ediff-regions-internal can't handle (non-overlapping) regions in   the same buffer
  2005-12-07 20:59 ediff-regions-internal can't handle (non-overlapping) regions in the same buffer Kevin Rodgers
@ 2005-12-09 16:47 ` Kevin Rodgers
  2005-12-12 18:24   ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2005-12-09 16:47 UTC (permalink / raw)


Kevin Rodgers wrote:
> I'm working on a way to take advantage of Ediff's fine highlighting
> feature within Diff mode buffers.  But calling ediff-regions-internal
> programmatically with BUFFER-A the same as BUFFER-B doesn't work,
> leaving only the region between BEG-B and END-B highighted.  This is
> because ediff-extract-diffs first resets point in both buffers (changing
> point in BUFFER-A unintentionally), then builds the diff vector by
> moving by lines in each buffer.
> 
> The fix is simple, and it allows ediff-regions-internal to work with
> non-overlapping regions in the same buffer: Don't set point in each
> buffer until necessary:

Sorry, that patch breaks Ediff horribly.  I'll get to work on a proper
fix.

-- 
Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ediff-regions-internal can't handle (non-overlapping) regions in   the same buffer
  2005-12-09 16:47 ` Kevin Rodgers
@ 2005-12-12 18:24   ` Kevin Rodgers
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2005-12-12 18:24 UTC (permalink / raw)


Kevin Rodgers wrote:
> Kevin Rodgers wrote:
>> I'm working on a way to take advantage of Ediff's fine highlighting
>> feature within Diff mode buffers.  But calling ediff-regions-internal
>> programmatically with BUFFER-A the same as BUFFER-B doesn't work,
>> leaving only the region between BEG-B and END-B highighted.  This is
>> because ediff-extract-diffs first resets point in both buffers (changing
>> point in BUFFER-A unintentionally), then builds the diff vector by
>> moving by lines in each buffer.
>>
>> The fix is simple, and it allows ediff-regions-internal to work with
>> non-overlapping regions in the same buffer: Don't set point in each
>> buffer until necessary:
> 
> 
> Sorry, that patch breaks Ediff horribly.  I'll get to work on a proper
> fix.

Here it is:

2005-12-09  Kevin Rodgers  <ihs_4664@yahoo.com>
	
	* ediff-diffs.el (ediff-extract-diffs): Keep track of point in
	buffers A and B in new local variables a-prev-pt and b-prev-pt,
	in case A and B are the same; and make sure to restore point in
	buffers A and B before calling forward-line to convert lines to
	points.

*** emacs-21.4/lisp/ediff-diff.el~	Wed Jul  3 10:49:40 2002
--- emacs-21.4/lisp/ediff-diff.el	Fri Dec  9 12:22:12 2005
***************
*** 361,367 ****
--- 361,369 ----
   	(B-buffer ediff-buffer-B)
   	(C-buffer ediff-buffer-C)
   	(a-prev 1) ; this is needed to set the first diff line correctly
+ 	(a-prev-pt nil)
   	(b-prev 1)
+ 	(b-prev-pt nil)
   	(c-prev 1)
   	diff-list shift-A shift-B
   	)
***************
*** 378,388 ****
   	      (ediff-overlay-start
   	       (ediff-get-value-according-to-buffer-type 'B bounds))))

!     ;; reset point in buffers A/B/C
!     (ediff-with-current-buffer A-buffer
!       (goto-char (if shift-A shift-A (point-min))))
!     (ediff-with-current-buffer B-buffer
!       (goto-char (if shift-B shift-B (point-min))))
       (if (ediff-buffer-live-p C-buffer)
   	(ediff-with-current-buffer C-buffer
   	  (goto-char (point-min))))
--- 380,386 ----
   	      (ediff-overlay-start
   	       (ediff-get-value-according-to-buffer-type 'B bounds))))

!     ;; reset point in buffer C
       (if (ediff-buffer-live-p C-buffer)
   	(ediff-with-current-buffer C-buffer
   	  (goto-char (point-min))))
***************
*** 456,472 ****
   		   c-prev c-end)
   	   ;; else convert lines to points
   	   (ediff-with-current-buffer A-buffer
   	     (forward-line (- a-begin a-prev))
   	     (setq a-begin-pt (point))
   	     (forward-line (- a-end a-begin))
   	     (setq a-end-pt (point)
! 		   a-prev a-end))
   	   (ediff-with-current-buffer B-buffer
   	     (forward-line (- b-begin b-prev))
   	     (setq b-begin-pt (point))
   	     (forward-line (- b-end b-begin))
   	     (setq b-end-pt (point)
! 		   b-prev b-end))
   	   (if (ediff-buffer-live-p C-buffer)
   	       (ediff-with-current-buffer C-buffer
   		 (forward-line (- c-begin c-prev))
--- 454,474 ----
   		   c-prev c-end)
   	   ;; else convert lines to points
   	   (ediff-with-current-buffer A-buffer
+              (goto-char (or a-prev-pt shift-A (point-min)))
   	     (forward-line (- a-begin a-prev))
   	     (setq a-begin-pt (point))
   	     (forward-line (- a-end a-begin))
   	     (setq a-end-pt (point)
! 		   a-prev a-end
!                    a-prev-pt a-end-pt))
   	   (ediff-with-current-buffer B-buffer
+              (goto-char (or b-prev-pt shift-B (point-min)))
   	     (forward-line (- b-begin b-prev))
   	     (setq b-begin-pt (point))
   	     (forward-line (- b-end b-begin))
   	     (setq b-end-pt (point)
! 		   b-prev b-end
!                    b-prev-pt b-end-pt))
   	   (if (ediff-buffer-live-p C-buffer)
   	       (ediff-with-current-buffer C-buffer
   		 (forward-line (- c-begin c-prev))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-12-12 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-07 20:59 ediff-regions-internal can't handle (non-overlapping) regions in the same buffer Kevin Rodgers
2005-12-09 16:47 ` Kevin Rodgers
2005-12-12 18:24   ` Kevin Rodgers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).