aboutsummaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2007-08-29 13:20:34 +0000
committerLudovic Court`es2007-08-29 13:20:34 +0000
commit2da2bb053a1cc252c71966135e7a9b675649ff1d (patch)
treec80ec76727a0911cee8bec5f0bcc31ceeda106d1 /src/guile
parent40ecaa4ffb5e6e95910783caf06ae75d81359641 (diff)
parent5d9b0e84c21a4d87e204b0f28a3e60d3f297d4ab (diff)
downloadskribilo-2da2bb053a1cc252c71966135e7a9b675649ff1d.tar.gz
skribilo-2da2bb053a1cc252c71966135e7a9b675649ff1d.tar.lz
skribilo-2da2bb053a1cc252c71966135e7a9b675649ff1d.zip
biblio: Improved `bib-sort/first-author-last-name'.
* src/guile/skribilo/biblio/author.scm (bib-sort/first-author-last-name)[entry-field, <=?]: New. Use them such that ordering also takes `year' and `title' into account. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-154
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo/biblio/author.scm33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/guile/skribilo/biblio/author.scm b/src/guile/skribilo/biblio/author.scm
index e842780..fe4e0e6 100644
--- a/src/guile/skribilo/biblio/author.scm
+++ b/src/guile/skribilo/biblio/author.scm
@@ -129,11 +129,30 @@
(define (bib-sort/first-author-last-name entries)
- ;; May be passed as the `:sort' argument of `the-bibliography'.
+ ;; May be passed as the `:sort' argument of `the-bibliography'.
+
+ (define (entry-field entry name)
+ (let ((o (markup-option entry name)))
+ (and o (markup-body o))))
+
+ (define (<=? e1 e2 field fail)
+ (let ((f1 (entry-field e1 field))
+ (f2 (entry-field e2 field)))
+ (cond ((and (string? f1) (string? f2))
+ (if (string-ci=? f1 f2)
+ (fail)
+ (string-ci<=? f1 f2)))
+ ((and (number? f1) (number? f2))
+ (if (= f1 f2)
+ (fail)
+ (<= f1 f2)))
+ (else
+ (fail)))))
+
(let ((check-author (lambda (e)
(if (not (markup-option e 'author))
- (skribe-error 'web
- "No author for this bib entry"
+ (skribe-error 'bib-sort/first-author-last-name
+ "no author for this bib entry"
(markup-ident e))
#t))))
(sort entries
@@ -144,7 +163,13 @@
(markup-body (markup-option e1 'author))))
(a2 (first-author-last-name
(markup-body (markup-option e2 'author)))))
- (string-ci<=? a1 a2)))))))
+ (if (string-ci=? a1 a2)
+ (<=? e1 e2 'year
+ (lambda ()
+ (<=? e1 e2 'title
+ (lambda ()
+ #f))))
+ (string-ci<=? a1 a2))))))))
;;; arch-tag: c9a1ef10-a2cd-4a06-bd35-fbdee1abf09a