summaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2007-03-16 17:10:38 +0000
committerLudovic Court`es2007-03-16 17:10:38 +0000
commit20e07303a9da769e56feb90c252ee0a66369b52d (patch)
treefbd15acee4edaf01d480eba2fb68c85f72c41bbc /src/guile
parent1ebc6400a3b1ba3e6111745ae95fcd858749f258 (diff)
parentb594657ce02d1d79a1eec77178637436d5703462 (diff)
downloadskribilo-20e07303a9da769e56feb90c252ee0a66369b52d.tar.gz
skribilo-20e07303a9da769e56feb90c252ee0a66369b52d.tar.lz
skribilo-20e07303a9da769e56feb90c252ee0a66369b52d.zip
`diff' package: Various fixes.
* src/guile/skribilo/package/diff.scm (%undiffable-markups): Added `numref' and `eq'. (make-diff-document)[undiffable?]: New. For containers, check whether they are undiffable. For lists, iterate until AST2 is empty, not until the smallest is empty. Added an `(equal? ast1 ast2)' cond clause. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-66
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo/package/diff.scm39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/guile/skribilo/package/diff.scm b/src/guile/skribilo/package/diff.scm
index 6e8c60b..116a6bd 100644
--- a/src/guile/skribilo/package/diff.scm
+++ b/src/guile/skribilo/package/diff.scm
@@ -166,7 +166,8 @@
(define %undiffable-markups
;; List of markups to not diff.
- '(ref url-ref bib-ref bib-ref+ line-ref unref
+ '(ref url-ref bib-ref bib-ref+ line-ref unref numref
+ eq ;; XXX: not supported because of the `eq-evaluate' thing
figref ;; non-standard
mark
image symbol lout-illustration
@@ -197,7 +198,12 @@
(define (make-diff-document ast1 ast2)
;; Return a document based on AST2 that highlights differences between AST1
- ;; and AST2, enclosing unchanged parts in `unchanged' markups, etc.
+ ;; and AST2, enclosing unchanged parts in `unchanged' markups, etc. AST2
+ ;; is used as the "reference" tree, thus changes from AST1 to AST2 are
+ ;; shown in the resulting document.
+ (define (undiffable? kind)
+ (memq kind %undiffable-markups))
+
(let loop ((ast1 ast1)
(ast2 ast2))
;;(format (current-error-port) "diff: ~a ~a~%" ast1 ast2)
@@ -240,10 +246,13 @@
(ident ident)
(class class)
(options opts)
- (body (loop (if (markup? ast1)
- (markup-body ast1)
- ast1)
- body)))))
+ (body (if (undiffable? kind)
+ body
+ (loop (if (and (container? ast1)
+ (is-markup? ast1 kind))
+ (markup-body ast1)
+ ast1)
+ body))))))
((markup? ast2)
(let ((kind (markup-markup ast2))
@@ -256,20 +265,32 @@
(ident ident)
(class class)
(options opts)
- (body (if (memq kind %undiffable-markups)
+ (body (if (undiffable? kind)
body
- (loop (if (markup? ast1)
+ (loop (if (is-markup? ast1 kind)
(markup-body ast1)
ast1)
body))))))
((list? ast2)
(if (list? ast1)
- (map loop ast1 ast2)
+ (let liip ((ast1 ast1)
+ (ast2 ast2)
+ (result '()))
+ (if (null? ast2)
+ (reverse! result)
+ (liip (if (null? ast1) ast1 (cdr ast1))
+ (cdr ast2)
+ (cons (loop (if (null? ast1) #f (car ast1))
+ (car ast2))
+ result))))
(map (lambda (x)
(loop ast1 x))
ast2)))
+ ((equal? ast1 ast2)
+ (unchanged ast1))
+
(else
(insertion ast2)))))