From Marc.Battyani at fractalconcept.com Wed Sep 1 09:45:17 2004 From: Marc.Battyani at fractalconcept.com (Marc Battyani) Date: Wed, 1 Sep 2004 11:45:17 +0200 Subject: [cl-typesetting-devel] [ANNOUNCE] A Common Lisp source code typesetter Message-ID: <28d901c49008$658ddab0$0a02a8c0@marcxp> I've added a module to typeset Common Lisp code with some syntax coloring to cl-typesetting. The syntax coloring is too simple to be 100% accurate: Improvements welcomed! (Multiple lines strings are not handled for instance) As an obvious example, I used this code to typeset itself ;-) The result is here: http://www.fractalconcept.com/pprint.pdf This module + cl-typegraph are the base layers for the automatic generation of documentation for Common Lisp code. The idea is to use XRefs tools like Albert or the ones from the CMU lisp repository to extract and generate some interesting documentation from the analysis of a bunch of source files. (Examples of graphs are on page 3 of the cl-typesetting example. The first one is a class hierarchy. See: http://www.fractalconcept.com/ex.pdf) The cl-typesetting repository is here: http://www.fractalconcept.com:8000/public/open-source/ And the latest tarball is here: http://www.fractalconcept.com/download/cl-typesetting-current.tgz Marc From marc.battyani at fractalconcept.com Mon Sep 6 15:10:50 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Mon, 6 Sep 2004 17:10:50 +0200 Subject: [cl-typesetting-devel] Page References References: <40A7DFE2.8050707@liberatinginsight.com> <1f5001c43be4$84db18b0$0a02a8c0@marcxp> <20040517165821.GA26376@w-m-p.com> <005d01c43c5a$3cb19250$0a02a8c0@marcxp> <20040517221752.GB27985@w-m-p.com> Message-ID: <416901c49423$b4046690$0a02a8c0@marcxp> I'm going to more tightly integrate Klaus Weidner's page references stuff in cl-typesetting/cl-pdf. Before I do this, has anybody worked on this subject ? (Any corrections, improvements, etc. ?) Marc From marc.battyani at fractalconcept.com Wed Sep 8 21:21:58 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Wed, 8 Sep 2004 23:21:58 +0200 Subject: [cl-typesetting-devel] cl-typesetting repository update References: <091c01c4375f$dce93bb0$0a02a8c0@marcxp> Message-ID: <04de01c495e9$e06f5dd0$0a02a8c0@marcxp> I've commited the latest modifications to the cl-typesetting repository. Rev 61: (You will need to get the latest cl-pdf version to use this revision) Added references and contextual values Added #'format-string Splitted the ASDF file in 3 Rev 59: Added Lisp source code typesetting (in pprint.lisp) + some fixes Rev 55 First version of cl-typegraph. :) Updated the full-example. Moved the test file from the cl-typesetting system to a cl-typesetting-test system. The full repository is here: http://www.fractalconcept.com:8000/public/open-source/ (It's a subversion 1.0 repository.) The cl-pdf part: http://www.fractalconcept.com:8000/public/open-source/cl-pdf/ The cl-typesetting part: http://www.fractalconcept.com:8000/public/open-source/cl-typesetting/ The mod_lisp part: http://www.fractalconcept.com:8000/public/open-source/mod_lisp/ There are also tarballs for cl-pdf and cl-typesetting: http://www.fractalconcept.com/download/cl-pdf-current.tgz http://www.fractalconcept.com/download/cl-typesetting-current.tgz BTW the (somewhat outdated) home pages for these projects are here: http://www.fractalconcept.com/asp/html/cl-pdf.html http://www.fractalconcept.com/asp/html/cl-typesetting.html http://www.fractalconcept.com/asp/html/mod_lisp.html Marc From Marc.Battyani at fractalconcept.com Thu Sep 9 17:46:08 2004 From: Marc.Battyani at fractalconcept.com (Marc Battyani) Date: Thu, 9 Sep 2004 19:46:08 +0200 Subject: [cl-typesetting-devel] cl-pdf and cl-typesetting portability Message-ID: <034301c49694$e6109870$0a02a8c0@marcxp> I know that cl-pdf and cl-typesetting work very well with LispWorks as it's the Lisp implementation I use daily. But I would like to know how it works on other implementations. For instance I've been told that there are again some problems with the zlib FFI binding for SBCL and maybe CMUCL. (This zlib FFI has proven to be the major annoyance.) Another portability problem was the under-specification of the LOOP behaviour in the standard, which caused problems with Lisps not using a MIT based LOOP, like CLisp. So far it's solved by switching to ITERATE which is better than LOOP anyway ;-) Other problems/patches/etc. ? Thanks, Marc The full repository is here: http://www.fractalconcept.com:8000/public/open-source/ (It's a subversion 1.0 repository.) The cl-pdf part: http://www.fractalconcept.com:8000/public/open-source/cl-pdf/ The cl-typesetting part: http://www.fractalconcept.com:8000/public/open-source/cl-typesetting/ The mod_lisp part: http://www.fractalconcept.com:8000/public/open-source/mod_lisp/ There are also tarballs for cl-pdf and cl-typesetting: http://www.fractalconcept.com/download/cl-pdf-current.tgz http://www.fractalconcept.com/download/cl-typesetting-current.tgz The (somewhat outdated) home pages for these projects are here: http://www.fractalconcept.com/asp/html/cl-pdf.html http://www.fractalconcept.com/asp/html/cl-typesetting.html http://www.fractalconcept.com/asp/html/mod_lisp.html From peter at javamonkey.com Sun Sep 12 20:06:17 2004 From: peter at javamonkey.com (Peter Seibel) Date: Sun, 12 Sep 2004 13:06:17 -0700 Subject: [cl-typesetting-devel] patch for double comment bug in pprint.lisp Message-ID: This patch fixes a bug in pprint.lisp that causes it to duplicate end-of-line comments. -Peter Index: pprint.lisp =================================================================== --- pprint.lisp (revision 59) +++ pprint.lisp (working copy) @@ -76,7 +76,7 @@ (setf start end-tok)) (with-text-compilation (when (< start length) - (verbatim (subseq line start))) + (verbatim (subseq cleaned-line start))) (with-style (:font (first *pp-comment-decoration*) :font-size *pp-font-size* :color (second *pp-comment-decoration*)) -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From peter at javamonkey.com Sun Sep 12 20:31:59 2004 From: peter at javamonkey.com (Peter Seibel) Date: Sun, 12 Sep 2004 13:31:59 -0700 Subject: [cl-typesetting-devel] patch for double comment bug in pprint.lisp In-Reply-To: (Peter Seibel's message of "Sun, 12 Sep 2004 13:06:17 -0700") References: Message-ID: Peter Seibel writes: > This patch fixes a bug in pprint.lisp that causes it to duplicate > end-of-line comments. Ah. Never mind that patch. It fixes the bug but adds a new one. Maybe someone who understands what cleaned-line is for can fix it the right way. A quick and dirty fix was to change (subseq line start) to (subseq line start (position #\; line)) but that's sort of kludgy. -Peter > > -Peter > > Index: pprint.lisp > =================================================================== > --- pprint.lisp (revision 59) > +++ pprint.lisp (working copy) > @@ -76,7 +76,7 @@ > (setf start end-tok)) > (with-text-compilation > (when (< start length) > - (verbatim (subseq line start))) > + (verbatim (subseq cleaned-line start))) > (with-style (:font (first *pp-comment-decoration*) > :font-size *pp-font-size* > :color (second *pp-comment-decoration*)) > > -- > Peter Seibel peter at javamonkey.com > > Lisp is the red pill. -- John Fraser, comp.lang.lisp > > _______________________________________________ > cl-typesetting-devel site list > cl-typesetting-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-typesetting-devel > -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Sun Sep 12 20:51:57 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 12 Sep 2004 22:51:57 +0200 Subject: [cl-typesetting-devel] patch for double comment bug in pprint.lisp References: Message-ID: <011001c4990a$58a0c370$0a04a8c0@marcxp> "Peter Seibel" wrote: > > This patch fixes a bug in pprint.lisp that causes it to duplicate > > end-of-line comments. > > Ah. Never mind that patch. It fixes the bug but adds a new one. Maybe > someone who understands what cleaned-line is for can fix it the right > way. A quick and dirty fix was to change (subseq line start) to > (subseq line start (position #\; line)) but that's sort of kludgy. Yes, you will miss the end of the line when there is no comment. It's probably: (verbatim (subseq code start))) (Not tested yet ;-) Marc From marc.battyani at fractalconcept.com Fri Sep 24 12:20:26 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 24 Sep 2004 14:20:26 +0200 Subject: [cl-typesetting-devel] Couple of notes References: <28d901c49008$658ddab0$0a02a8c0@marcxp> <000001c4a140$1cddbfd0$ca4302c3@digo> Message-ID: <12d601c4a230$e0ac61a0$0a04a8c0@marcxp> Dmitri Ivanov wrote: Hi Dmitri, > The references addition seems to work fine. Other improvements also works on > LWW 4.3 (except that I haven't tested cl-typegraph and pprint). Below are > two little notes. Good. These days I generate 1300+ pages documents with thousands of references and indeed it seems to be ok. > 1. cl-typsetting system definition > Modules "top-level" and "pprint" should depend on "references". > > 2. top-level.lisp : draw-block enhanced by the background-color parameter > > (defmethod draw-block (content x y dx dy &key border background-color > (padding 5) rotation (v-align > :top) > special-fn) > ;;; On the current *page* > (pdf:with-saved-state > (pdf:translate x y) > (when rotation > (pdf:rotate rotation)) > (with-quad (left top right bottom) padding > (when border (pdf:set-line-width border) (pdf:set-gray-stroke 0)) > (cond (background-color (pdf:set-color-fill background-color)) > (border (pdf:set-gray-fill 1))) > (when (or border background-color) > (pdf:basic-rect (- left) top (+ dx left right) (- (+ dy top > bottom)))) > (cond (border (pdf:fill-and-stroke)) > (background-color (pdf:fill-path))) > (cond (background-color (pdf:set-color-fill 0)) > (border (pdf:set-gray-fill 0))) ) > (let ((vbox (make-filled-vbox content dx dy v-align))) > ;(push vbox *boxes*) > (when special-fn > (funcall special-fn vbox 0 0)) > (stroke vbox 0 0)))) OK, I will add this. Now I'm leaving to go to the Amsterdam's Lisp meeting. :) Marc From hutch at recursive.ca Mon Sep 27 19:54:41 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Mon, 27 Sep 2004 15:54:41 -0400 Subject: [cl-typesetting-devel] peculiar behaviour Message-ID: <120E0965-10BF-11D9-9EA5-000A95728F12@recursive.ca> Hi, I'm starting to look into the cl-typesetting package and am encountering some very strange behaviour. I tried this bit of lisp: (iter (for i from 1 to 30) (tt::pprint-lisp-file (pathname "/Users/hutch/cl/cl-typesetting/pprint.lisp") (pathname (format nil "/tmp/pprint~A.pdf" i)) "pprint of pprint")) Which runs without reporting any problems. Check out the sizes of the files produced: 8363 Sep 27 15:45 pprint1.pdf 5186 Sep 27 15:45 pprint2.pdf 5282 Sep 27 15:45 pprint3.pdf 5460 Sep 27 15:45 pprint4.pdf 5681 Sep 27 15:45 pprint5.pdf 5794 Sep 27 15:45 pprint6.pdf 5925 Sep 27 15:45 pprint7.pdf 5991 Sep 27 15:45 pprint8.pdf 6053 Sep 27 15:45 pprint9.pdf 6193 Sep 27 15:45 pprint10.pdf 6253 Sep 27 15:45 pprint11.pdf 6405 Sep 27 15:45 pprint12.pdf 6443 Sep 27 15:45 pprint13.pdf 6564 Sep 27 15:45 pprint14.pdf 6663 Sep 27 15:45 pprint15.pdf 6836 Sep 27 15:45 pprint16.pdf 6889 Sep 27 15:45 pprint17.pdf 6983 Sep 27 15:45 pprint18.pdf 7092 Sep 27 15:45 pprint19.pdf 7172 Sep 27 15:45 pprint20.pdf 7360 Sep 27 15:46 pprint21.pdf 7374 Sep 27 15:46 pprint22.pdf 8265 Sep 27 15:46 pprint23.pdf 5030 Sep 27 15:46 pprint24.pdf 5219 Sep 27 15:46 pprint25.pdf 5321 Sep 27 15:46 pprint26.pdf 5580 Sep 27 15:46 pprint27.pdf 5708 Sep 27 15:46 pprint28.pdf 5835 Sep 27 15:46 pprint29.pdf 5975 Sep 27 15:46 pprint30.pdf A quick look at the pdf files shows that varying amounts of content is missing from the beginning of the document. Is this something unique to my setup (LW for mac) or are other people seeing this too? I first saw this when I was playing with the kw-extensions. Cheers, Bob From hutch at recursive.ca Wed Sep 29 20:46:52 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Wed, 29 Sep 2004 16:46:52 -0400 Subject: [cl-typesetting-devel] peculiar behaviour Message-ID: Hi, I emailed this a couple of days ago and have not seen it come up yet on the mailing list, so trying again. Cheers, Bob Begin forwarded message: > From: Bob Hutchison > Date: September 27, 2004 3:54:41 PM EDT > To: cl-typesetting-devel at common-lisp.net > Cc: Bob Hutchison > Subject: peculiar behaviour > > Hi, > > I'm starting to look into the cl-typesetting package and am > encountering some very strange behaviour. > > I tried this bit of lisp: > > (iter (for i from 1 to 30) > (tt::pprint-lisp-file > (pathname "/Users/hutch/cl/cl-typesetting/pprint.lisp") > (pathname (format nil "/tmp/pprint~A.pdf" i)) > "pprint of pprint")) > > Which runs without reporting any problems. > > Check out the sizes of the files produced: > > 8363 Sep 27 15:45 pprint1.pdf > 5186 Sep 27 15:45 pprint2.pdf > 5282 Sep 27 15:45 pprint3.pdf > 5460 Sep 27 15:45 pprint4.pdf > 5681 Sep 27 15:45 pprint5.pdf > 5794 Sep 27 15:45 pprint6.pdf > 5925 Sep 27 15:45 pprint7.pdf > 5991 Sep 27 15:45 pprint8.pdf > 6053 Sep 27 15:45 pprint9.pdf > 6193 Sep 27 15:45 pprint10.pdf > 6253 Sep 27 15:45 pprint11.pdf > 6405 Sep 27 15:45 pprint12.pdf > 6443 Sep 27 15:45 pprint13.pdf > 6564 Sep 27 15:45 pprint14.pdf > 6663 Sep 27 15:45 pprint15.pdf > 6836 Sep 27 15:45 pprint16.pdf > 6889 Sep 27 15:45 pprint17.pdf > 6983 Sep 27 15:45 pprint18.pdf > 7092 Sep 27 15:45 pprint19.pdf > 7172 Sep 27 15:45 pprint20.pdf > 7360 Sep 27 15:46 pprint21.pdf > 7374 Sep 27 15:46 pprint22.pdf > 8265 Sep 27 15:46 pprint23.pdf > 5030 Sep 27 15:46 pprint24.pdf > 5219 Sep 27 15:46 pprint25.pdf > 5321 Sep 27 15:46 pprint26.pdf > 5580 Sep 27 15:46 pprint27.pdf > 5708 Sep 27 15:46 pprint28.pdf > 5835 Sep 27 15:46 pprint29.pdf > 5975 Sep 27 15:46 pprint30.pdf > > A quick look at the pdf files shows that varying amounts of content is > missing from the beginning of the document. > > Is this something unique to my setup (LW for mac) or are other people > seeing this too? I first saw this when I was playing with the > kw-extensions. > > Cheers, > Bob > From marc.battyani at fractalconcept.com Thu Sep 30 10:48:25 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 12:48:25 +0200 Subject: [cl-typesetting-devel] peculiar behaviour References: Message-ID: <12fe01c4a6db$03c35c80$0a02a8c0@marcxp> "Bob Hutchison" wrote: > I emailed this a couple of days ago and have not seen it come up yet on > the mailing list, so trying again. I got it but have not found the time to look at it until now. > I'm starting to look into the cl-typesetting package and am > encountering some very strange behaviour. > > I tried this bit of lisp: > > (iter (for i from 1 to 30) > (tt::pprint-lisp-file > (pathname "/Users/hutch/cl/cl-typesetting/pprint.lisp") > (pathname (format nil "/tmp/pprint~A.pdf" i)) > "pprint of pprint")) > > Which runs without reporting any problems. > > A quick look at the pdf files shows that varying amounts of content is > missing from the beginning of the document. > > Is this something unique to my setup (LW for mac) or are other people > seeing this too? I first saw this when I was playing with the > kw-extensions. A binding of pdf:*page* was missing so a fresh page was not enforced at the beginning of a with-document. Try with this in pdf.lisp of cl-pdf: (defmacro with-document ((&rest args) &body body) `(let* ((*document* (make-instance 'document , at args)) (*outlines-stack* (list (outline-root *document*))) (*root-page* (root-page *document*)) (*page* nil) (*page-number* 0)) , at body)) This should fix it. Tell me if it's OK. Marc From hutch at recursive.ca Thu Sep 30 12:36:28 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 08:36:28 -0400 Subject: [cl-typesetting-devel] peculiar behaviour In-Reply-To: <12fe01c4a6db$03c35c80$0a02a8c0@marcxp> References: <12fe01c4a6db$03c35c80$0a02a8c0@marcxp> Message-ID: <59EB48C6-12DD-11D9-9320-000A95728F12@recursive.ca> On Sep 30, 2004, at 6:48 AM, Marc Battyani wrote: > "Bob Hutchison" wrote: > >> I emailed this a couple of days ago and have not seen it come up yet >> on >> the mailing list, so trying again. > > I got it but have not found the time to look at it until now. I was afraid of that. Sorry to pester. > > A binding of pdf:*page* was missing so a fresh page was not enforced > at the > beginning of a with-document. > > Try with this in pdf.lisp of cl-pdf: > > (defmacro with-document ((&rest args) &body body) > `(let* ((*document* (make-instance 'document , at args)) > (*outlines-stack* (list (outline-root *document*))) > (*root-page* (root-page *document*)) > (*page* nil) > (*page-number* 0)) > , at body)) > > This should fix it. Tell me if it's OK. > It is much better now. The sizes are not quite the same, but I cannot *see* anything different between them. The creation dates are all different, of course. The fonts?? are different (there is likely a counter not being reset, and this may not matter): pprint1.pdf has: /Font << /CLF104 10 0 R /CLF103 9 0 R /CLF102 8 0 R /CLF101 7 0 R >> pprint2.pdf has: /Font << /CLF108 10 0 R /CLF107 9 0 R /CLF106 8 0 R /CLF105 7 0 R >> More interestingly the the compressed code has differing lengths: pprint1.pdf has: << /Filter /FlateDecode /Length 3028 >> pprint2.pdf has: << /Filter /FlateDecode /Length 3027 >> I have no idea if this is significant, for all I know something insignificant like the creation date, or I suppose the different font numbers, may be in the compressed data and accounts for this difference. Anyway, this is is *much* better. It is *so* much easier to see the results of my mucking about :-) Thanks Marc. Cheers, Bob 9707 Sep 30 08:14 pprint1.pdf 8706 Sep 30 08:14 pprint2.pdf 8711 Sep 30 08:14 pprint3.pdf 8706 Sep 30 08:14 pprint4.pdf 8706 Sep 30 08:14 pprint5.pdf 8706 Sep 30 08:14 pprint6.pdf 8707 Sep 30 08:14 pprint7.pdf 8711 Sep 30 08:14 pprint8.pdf 8708 Sep 30 08:14 pprint9.pdf 8706 Sep 30 08:14 pprint10.pdf 8706 Sep 30 08:14 pprint11.pdf 8709 Sep 30 08:14 pprint12.pdf 8712 Sep 30 08:14 pprint13.pdf 8707 Sep 30 08:14 pprint14.pdf 8706 Sep 30 08:14 pprint15.pdf 8706 Sep 30 08:14 pprint16.pdf 8708 Sep 30 08:14 pprint17.pdf 8715 Sep 30 08:14 pprint18.pdf 8707 Sep 30 08:14 pprint19.pdf 8707 Sep 30 08:14 pprint20.pdf 8706 Sep 30 08:14 pprint21.pdf 8705 Sep 30 08:14 pprint22.pdf 8712 Sep 30 08:14 pprint23.pdf 8707 Sep 30 08:14 pprint24.pdf 8706 Sep 30 08:14 pprint25.pdf 8705 Sep 30 08:14 pprint26.pdf 8707 Sep 30 08:14 pprint27.pdf 8711 Sep 30 08:14 pprint28.pdf 8706 Sep 30 08:14 pprint29.pdf 8706 Sep 30 08:14 pprint30.pdf From marc.battyani at fractalconcept.com Thu Sep 30 12:56:28 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 14:56:28 +0200 Subject: [cl-typesetting-devel] peculiar behaviour References: <12fe01c4a6db$03c35c80$0a02a8c0@marcxp> <59EB48C6-12DD-11D9-9320-000A95728F12@recursive.ca> Message-ID: <137c01c4a6ec$e6fd5030$0a02a8c0@marcxp> Bob Hutchison wrote: > On Sep 30, 2004, at 6:48 AM, Marc Battyani wrote: > > > This should fix it. Tell me if it's OK. > > It is much better now. The sizes are not quite the same, but I cannot > *see* anything different between them. > > The creation dates are all different, of course. > > The fonts?? are different (there is likely a counter not being reset, > and this may not matter): Yes, we want unique identifiers (like gensym) > More interestingly the the compressed code has differing lengths: > > pprint1.pdf has: > > << /Filter /FlateDecode > /Length 3028 > >> > > pprint2.pdf has: > > << /Filter /FlateDecode > /Length 3027 > >> > I have no idea if this is significant, for all I know something > insignificant like the creation date, or I suppose the different font > numbers, may be in the compressed data and accounts for this > difference. Yes, different names and strings will give different compressed sizes. If you want to see what is in the streams, you can just disable the compression. > Anyway, this is is *much* better. It is *so* much easier to see the > results of my mucking about :-) Sure :) Cheers, Marc From peter at javamonkey.com Thu Sep 30 18:14:29 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 11:14:29 -0700 Subject: [cl-typesetting-devel] Page n of m? Message-ID: I haven't really spent much time on this, mostly because I somehow picked up the impression that it'd would be a pain. But maybe I'm wrong. Is there an easy way to typeset a document and generate something like a header with "Page n of m" in it where n is the current page number and m is the total number of pages. I've got "Page n" already but I have no idea to get the whole number of pages in advance. -Peter P.S. A more complex version of this is something like cross-references where I want to insert some text along the lines of (see page X) where X is determined at typesetting time based on where some anchor ended up getting placed. And of course there's the wrinkle that depending on the value of X, inserting the text might change the way the pages break. But maybe someone has solved this problem and I just missed it. -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From hutch at recursive.ca Thu Sep 30 18:47:31 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 14:47:31 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: References: Message-ID: <2F70CDF3-1311-11D9-9320-000A95728F12@recursive.ca> On Sep 30, 2004, at 2:14 PM, Peter Seibel wrote: > I haven't really spent much time on this, mostly because I somehow > picked up the impression that it'd would be a pain. But maybe I'm > wrong. Is there an easy way to typeset a document and generate > something like a header with "Page n of m" in it where n is the > current page number and m is the total number of pages. I've got "Page > n" already but I have no idea to get the whole number of pages in > advance. > > -Peter > > P.S. A more complex version of this is something like cross-references > where I want to insert some text along the lines of (see page X) where > X is determined at typesetting time based on where some anchor ended > up getting placed. And of course there's the wrinkle that depending on > the value of X, inserting the text might change the way the pages > break. But maybe someone has solved this problem and I just missed it. And lets not forget about footnotes :-) From peter at javamonkey.com Thu Sep 30 19:17:42 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 12:17:42 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <2F70CDF3-1311-11D9-9320-000A95728F12@recursive.ca> (Bob Hutchison's message of "Thu, 30 Sep 2004 14:47:31 -0400") References: <2F70CDF3-1311-11D9-9320-000A95728F12@recursive.ca> Message-ID: Bob Hutchison writes: > On Sep 30, 2004, at 2:14 PM, Peter Seibel wrote: > >> I haven't really spent much time on this, mostly because I somehow >> picked up the impression that it'd would be a pain. But maybe I'm >> wrong. Is there an easy way to typeset a document and generate >> something like a header with "Page n of m" in it where n is the >> current page number and m is the total number of pages. I've got "Page >> n" already but I have no idea to get the whole number of pages in >> advance. >> >> -Peter >> >> P.S. A more complex version of this is something like cross-references >> where I want to insert some text along the lines of (see page X) where >> X is determined at typesetting time based on where some anchor ended >> up getting placed. And of course there's the wrinkle that depending on >> the value of X, inserting the text might change the way the pages >> break. But maybe someone has solved this problem and I just missed it. > > And lets not forget about footnotes :-) Indeed. -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Thu Sep 30 19:57:17 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 21:57:17 +0200 Subject: [cl-typesetting-devel] Page n of m? References: Message-ID: <142101c4a727$b0585a80$0a02a8c0@marcxp> Peter Seibel wrote: > I haven't really spent much time on this, mostly because I somehow > picked up the impression that it'd would be a pain. But maybe I'm > wrong. Is there an easy way to typeset a document and generate > something like a header with "Page n of m" in it where n is the > current page number and m is the total number of pages. I've got "Page > n" already but I have no idea to get the whole number of pages in > advance. > > -Peter > > P.S. A more complex version of this is something like cross-references > where I want to insert some text along the lines of (see page X) where > X is determined at typesetting time based on where some anchor ended > up getting placed. And of course there's the wrinkle that depending on > the value of X, inserting the text might change the way the pages > break. But maybe someone has solved this problem and I just missed it. Hum, you should follow more closely the evolution of cl-typesetting ;-) What you want is called references and it's in references.lisp. If you want a reference to the last page of a document, just call something like (mark-ref-point :the-end) At the end of the document. And put this in your footer: (format-string "Page ~d of ~d" pdf:*page-number* (find-ref-point-page-number :the-end)) This works also for things like "(see page ~d)" See test.lisp for more details. Cheers, Marc From peter at javamonkey.com Thu Sep 30 20:14:39 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 13:14:39 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <142101c4a727$b0585a80$0a02a8c0@marcxp> (Marc Battyani's message of "Thu, 30 Sep 2004 21:57:17 +0200") References: <142101c4a727$b0585a80$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > Peter Seibel wrote: > > >> I haven't really spent much time on this, mostly because I somehow >> picked up the impression that it'd would be a pain. But maybe I'm >> wrong. Is there an easy way to typeset a document and generate >> something like a header with "Page n of m" in it where n is the >> current page number and m is the total number of pages. I've got "Page >> n" already but I have no idea to get the whole number of pages in >> advance. >> >> -Peter >> >> P.S. A more complex version of this is something like cross-references >> where I want to insert some text along the lines of (see page X) where >> X is determined at typesetting time based on where some anchor ended >> up getting placed. And of course there's the wrinkle that depending on >> the value of X, inserting the text might change the way the pages >> break. But maybe someone has solved this problem and I just missed it. > > Hum, you should follow more closely the evolution of cl-typesetting > ;-) What you want is called references and it's in references.lisp. Great! Next you're going to tell me you've already got a mechanism for doing footnotes. Hmmmm. Not quite. I did what you said but it thinks my document is 999 pages long. Here's the main bit of my code. Maybe I've just made some dumb mistake that you can point out: (defun sexp->pdf (paragraphs &optional (file #P"/tmp/hello.pdf")) (let ((*note-counter* 0) (*notes* nil)) (typeset:with-document () (let ((content (typeset::compile-text () (let ((*my-leading-ratio* 2.0)) (dolist (p paragraphs) (emit-pdf p))) (typeset::vspace 24) (typeset::hrule :dy .1) (typeset::vspace 6) (let ((*default-font-size* 10)) (loop for n in (nreverse *notes*) for counter from 1 do (emit-note counter n))) (typeset:mark-ref-point :the-end)))) (loop for page-number from 1 for header = (typeset::compile-text () (typeset::paragraph (:h-align :right :font "Times-Italic" :font-size 10) (typeset::put-string (format nil "~a~c~d of ~d" (second (first paragraphs)) +mdash+ pdf:*page-number* (typeset:find-ref-point-page-number :the-end))) :eol (typeset::put-string (format nil "Copyright ~c 2003-2004, Peter Seibel." +copyright+)) :eol (typeset::put-string (date-string)) :eol)) while (typeset::boxes content) do (draw-page content header :width 612 :height 792 :margins '(72 36 72 72) :header-height (- 108 36)))) (pdf:write-document file))) (truename file)) (defun draw-page (content header &key width height margins (header-height 12)) (destructuring-bind (left &optional (top left) (right left) (bottom top)) margins (let ((x left) (y (- height top)) (dx (- width left right)) (dy (- height top bottom))) (pdf:with-page (:bounds (vector 0 0 width height)) (pdf:with-saved-state (when header (typeset::stroke (typeset::make-filled-vbox header dx header-height :top) x y)) (typeset::stroke (typeset::make-filled-vbox content dx (- dy header-height) :top) x (- y header-height))))))) -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Thu Sep 30 20:39:36 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 22:39:36 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp> Message-ID: <149101c4a72d$99ef24d0$0a02a8c0@marcxp> Peter Seibel wrote: > "Marc Battyani" writes: > > > Hum, you should follow more closely the evolution of cl-typesetting > > ;-) What you want is called references and it's in references.lisp. > > Great! Next you're going to tell me you've already got a mechanism for > doing footnotes. > > Hmmmm. Not quite. I did what you said but it thinks my document is 999 > pages long. Here's the main bit of my code. Maybe I've just made some > dumb mistake that you can point out: The multipass mechnism is integrated into typeset:with-document so it should work in your code. As they are several passes you should use: (when (typeset::final-pass-p) (pdf:write-document file)) To avoid writing the pdf file during the intermediate passes. (I will probably redefine write-document in typeset to handle this more easily.) How many passes go you get ? What are the values of *current-pass* *undefined-references* *changed-references* ? Marc From hutch at recursive.ca Thu Sep 30 20:45:00 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 16:45:00 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: References: <142101c4a727$b0585a80$0a02a8c0@marcxp> Message-ID: <99371906-1321-11D9-985D-000A95728F12@recursive.ca> On Sep 30, 2004, at 4:14 PM, Peter Seibel wrote: > Great! Next you're going to tell me you've already got a mechanism for > doing footnotes. > > Hmmmm. Not quite. I did what you said but it thinks my document is 999 > pages long. Here's the main bit of my code. Maybe I've just made some > dumb mistake that you can point out: > It gets it right on the last page in my test (there are 17 pages), it says 999 on the first 16. Cheers, Bob From hutch at recursive.ca Thu Sep 30 20:58:12 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 16:58:12 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <149101c4a72d$99ef24d0$0a02a8c0@marcxp> References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> Message-ID: <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> On Sep 30, 2004, at 4:39 PM, Marc Battyani wrote: > The multipass mechnism is integrated into typeset:with-document so it > should > work in your code. > > As they are several passes you should use: > > (when (typeset::final-pass-p) > (pdf:write-document file)) This doesn't seem to make any difference. I'm not sure what happens if it isn't the final pass? how does the document get written? > > To avoid writing the pdf file during the intermediate passes. > (I will probably redefine write-document in typeset to handle this more > easily.) > > How many passes go you get ? > What are the values of *current-pass* *undefined-references* > *changed-references* ? I am getting current pass: 1, undefined references: NIL, changed-references: NIL Cheers, Bob From marc.battyani at fractalconcept.com Thu Sep 30 21:20:50 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 23:20:50 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> Message-ID: <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Bob Hutchison wrote: > On Sep 30, 2004, at 4:39 PM, Marc Battyani wrote: > > > The multipass mechnism is integrated into typeset:with-document so it > > should > > work in your code. > > > > As they are several passes you should use: > > > > (when (typeset::final-pass-p) > > (pdf:write-document file)) > > This doesn't seem to make any difference. I'm not sure what happens if > it isn't the final pass? how does the document get written? > > > > > To avoid writing the pdf file during the intermediate passes. > > (I will probably redefine write-document in typeset to handle this more > > easily.) > > > > How many passes go you get ? > > What are the values of *current-pass* *undefined-references* > > *changed-references* ? > > I am getting current pass: 1, undefined references: NIL, > changed-references: NIL This is not good. When the ref id is not yet defined, #'find-ref-point-page-number should push the missing ref id in *undefined-references*. This would start a second pass. Are you looking at the value of *undefined-references* just before the end of with-document ? (it's cleared at the beginning) Marc From peter at javamonkey.com Thu Sep 30 21:30:55 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 14:30:55 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <149101c4a72d$99ef24d0$0a02a8c0@marcxp> (Marc Battyani's message of "Thu, 30 Sep 2004 22:39:36 +0200") References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > Peter Seibel wrote: >> "Marc Battyani" writes: >> >> > Hum, you should follow more closely the evolution of cl-typesetting >> > ;-) What you want is called references and it's in references.lisp. >> >> Great! Next you're going to tell me you've already got a mechanism for >> doing footnotes. >> >> Hmmmm. Not quite. I did what you said but it thinks my document is 999 >> pages long. Here's the main bit of my code. Maybe I've just made some >> dumb mistake that you can point out: > > The multipass mechnism is integrated into typeset:with-document so it should > work in your code. > > As they are several passes you should use: > > (when (typeset::final-pass-p) > (pdf:write-document file)) > > To avoid writing the pdf file during the intermediate passes. > (I will probably redefine write-document in typeset to handle this more > easily.) > > How many passes go you get ? What are the values of *current-pass* > *undefined-references* *changed-references* ? Okay, I added some calls to this function: (defun show-refs () (format t "*current-pass*: ~a; *undefined-references*: ~a; *changed-references*: ~a; *max-number-of-passes*: ~a~%" typeset::*current-pass* typeset::*undefined-references* typeset::*changed-references* typeset::*max-number-of-passes*)) as shown here: (defun sexp->pdf (paragraphs &optional (file #P"/tmp/hello.pdf")) (let ((*note-counter* 0) (*notes* nil)) (typeset:with-document () (let ((content (typeset::compile-text () (let ((*my-leading-ratio* 2.0)) (dolist (p paragraphs) (emit-pdf p))) (typeset::vspace 24) (typeset::hrule :dy .1) (typeset::vspace 6) (let ((*default-font-size* 10)) (loop for n in (nreverse *notes*) for counter from 1 do (emit-note counter n))) (typeset:mark-ref-point :the-end)))) (loop for header = (typeset::compile-text () (typeset::paragraph (:h-align :right :font "Times-Italic" :font-size 10) (typeset::put-string (format nil "~a~c~d of ~d" (second (first paragraphs)) +mdash+ pdf:*page-number* (typeset:find-ref-point-page-number :the-end))) :eol (typeset::put-string (format nil "Copyright ~c 2003-2004, Peter Seibel." +copyright+)) :eol (typeset::put-string (date-string)) :eol)) while (typeset::boxes content) do (draw-page content header :width 612 :height 792 :margins '(72 36 72 72) :header-height (- 108 36)) (show-refs))) (show-refs) (pdf:write-document file))) (truename file)) and got this: CL-USER> (typeset-book "text/allegroserve.txt") *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 Chapter practical-web-programming-with-allegroserve: /home/peter/www.gigamonkeys.com/book/practical-web-programming-with-allegroserve.pdf NIL -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From peter at javamonkey.com Thu Sep 30 21:34:44 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 14:34:44 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <14da01c4a733$5cb987d0$0a02a8c0@marcxp> (Marc Battyani's message of "Thu, 30 Sep 2004 23:20:50 +0200") References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > Bob Hutchison wrote: >> On Sep 30, 2004, at 4:39 PM, Marc Battyani wrote: >> >> > The multipass mechnism is integrated into typeset:with-document so it >> > should >> > work in your code. >> > >> > As they are several passes you should use: >> > >> > (when (typeset::final-pass-p) >> > (pdf:write-document file)) >> >> This doesn't seem to make any difference. I'm not sure what happens if >> it isn't the final pass? how does the document get written? >> >> > >> > To avoid writing the pdf file during the intermediate passes. >> > (I will probably redefine write-document in typeset to handle this more >> > easily.) >> > >> > How many passes go you get ? >> > What are the values of *current-pass* *undefined-references* >> > *changed-references* ? >> >> I am getting current pass: 1, undefined references: NIL, >> changed-references: NIL > > This is not good. When the ref id is not yet defined, > #'find-ref-point-page-number should push the missing ref id in > *undefined-references*. This would start a second pass. So, it looks like in my case that it's finding the ref-point. It's just that the page-number slot of the ref point is set to 999 and is never getting reset. What's supposed to trigger that? -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From hutch at recursive.ca Thu Sep 30 21:43:40 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 17:43:40 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <14da01c4a733$5cb987d0$0a02a8c0@marcxp> References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: On Sep 30, 2004, at 5:20 PM, Marc Battyani wrote: > Bob Hutchison wrote: >>> >> >> I am getting current pass: 1, undefined references: NIL, >> changed-references: NIL > > This is not good. > When the ref id is not yet defined, #'find-ref-point-page-number > should push > the missing ref id in *undefined-references*. > This would start a second pass. > > Are you looking at the value of *undefined-references* just before the > end > of with-document ? > (it's cleared at the beginning) > > Marc > It seems that I was calling the mark-ref-point too soon (i.e. before the footer was built). I've appended the code I am using (it is based on the multi-page example in test.lisp). I added some format statements to some methods in references.lisp and this is what I'm getting. I also changed the initform of pagenumber to -1 from 999 so I could see the difference between the reference point not being defined and the initform. It seems that the page number is not being changed. find-ref-point 'END-OF-DOC' -- ref-point [NIL]/NIL/NIL find-ref-point-page-number UNKNOWN ;; this means that there is no ref-point yet find-ref-point 'END-OF-DOC' -- ref-point [#]/#/NIL find-ref-point-page-number -1 ;; now there is one, but the page number is -1 (the initform) current pass: 1, undefined references: (END-OF-DOC), changed-references: NIL find-ref-point 'END-OF-DOC' -- ref-point [#]/NIL/# find-ref-point-page-number -1 find-ref-point 'END-OF-DOC' -- ref-point [#]/#/# find-ref-point-page-number -1 current pass: 2, undefined references: NIL, changed-references: NIL WRITE THE DOCUMENT NOW And the code... (defun page-n-of-m (&optional (file #P"/tmp/page-n-of-m.pdf") &aux content (margins '(72 72 72 50))) (with-document () (let* ((print-stamp (multiple-value-bind (second minute hour date month year) (get-decoded-time) (declare (ignore second)) (format nil "Printed on ~4D-~2,'0D-~2,'0D ~2,'0D:~2,'0D" year month date hour minute))) (header (compile-text () (paragraph (:h-align :center :font "Helvetica-BoldOblique" :font-size 12) "Multi-page example document") (hrule :dy 1/2))) (footer (lambda (pdf:*page*) (compile-text (:font "Helvetica" :font-size 10) (hrule :dy 1/2) (hbox (:align :center :adjustable-p t) (verbatim print-stamp) :hfill (verbatim (format nil "Page ~d of ~d" pdf:*page-number* (tt::find-ref-point-page-number :end-of-doc)))))))) (setq content (compile-text () (paragraph (:font "Times-Bold" :font-size 16 :top-margin 20) "2. Second paragraph group" (hrule :dy 2)) (dotimes (i 40) (paragraph (:font "Times-Roman" :font-size (+ 6 (random 10))) (verbatim (format nil "2.~d. " (1+ i))) (dotimes (j (1+ (random 5))) (put-string "The quick brown fox jumps over the lazy dog. ")))) ;(tt::mark-ref-point :end-of-doc) <-- This won't work here )) (draw-pages content :margins margins :header header :footer footer)) (tt::mark-ref-point :end-of-doc) (when pdf:*page* (finalize-page pdf:*page*)) (format t "current pass: ~A, undefined references: ~A, changed-references: ~A~%" tt::*current-pass* tt::*undefined-references* tt::*changed-references*) (when (typeset::final-pass-p) (format t "WRITE THE DOCUMENT NOW~%") (pdf:write-document file)))) From marc.battyani at fractalconcept.com Thu Sep 30 21:44:10 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 23:44:10 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp><149101c4a72d$99ef24d0$0a02a8c0@marcxp> Message-ID: <150f01c4a736$9eb0b570$0a02a8c0@marcxp> Peter Seibel wrote: > "Marc Battyani" writes: > > > How many passes go you get ? What are the values of *current-pass* > > *undefined-references* *changed-references* ? > > Okay, I added some calls to this function: > > (defun show-refs () > (format > t "*current-pass*: ~a; *undefined-references*: ~a; *changed-references*: ~a; *max-number-of-passes*: ~a~%" > typeset::*current-pass* typeset::*undefined-references* typeset::*changed-references* > typeset::*max-number-of-passes*)) > > as shown here: > > (defun sexp->pdf (paragraphs &optional (file #P"/tmp/hello.pdf")) > (let ((*note-counter* 0) > (*notes* nil)) > (typeset:with-document () > (let ((content > (typeset::compile-text () > (let ((*my-leading-ratio* 2.0)) > (dolist (p paragraphs) (emit-pdf p))) > (typeset::vspace 24) > (typeset::hrule :dy .1) > (typeset::vspace 6) > (let ((*default-font-size* 10)) > (loop for n in (nreverse *notes*) > for counter from 1 > do (emit-note counter n))) > (typeset:mark-ref-point :the-end)))) > (loop > for header = (typeset::compile-text () > (typeset::paragraph > (:h-align :right :font "Times-Italic" :font-size 10) > (typeset::put-string (format nil "~a~c~d of ~d" (second (first paragraphs)) +mdash+ pdf:*page-number* (typeset:find-ref-point-page-number :the-end))) :eol > (typeset::put-string (format nil "Copyright ~c 2003-2004, Peter Seibel." +copyright+)) :eol > (typeset::put-string (date-string)) :eol)) > while (typeset::boxes content) > do (draw-page content header :width 612 :height 792 :margins '(72 36 72 72) :header-height (- 108 36)) > (show-refs))) > (show-refs) > (pdf:write-document file))) > (truename file)) > > and got this: > > CL-USER> (typeset-book "text/allegroserve.txt") > *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2 Can you add a trace of typeset:find-ref-point-page-number ? It should push the missing ref-id in *undefined-references* Also have you tested the full-example in test.lisp ? (It also uses forward references) This should work, I use refs in a 1300+ pages document, for the index and the table of content, and I have lots and lots of references without any pb. Marc From hutch at recursive.ca Thu Sep 30 21:53:25 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 17:53:25 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: <2786C372-132B-11D9-985D-000A95728F12@recursive.ca> On Sep 30, 2004, at 5:43 PM, Bob Hutchison wrote: > > On Sep 30, 2004, at 5:20 PM, Marc Battyani wrote: > >> Bob Hutchison wrote: >>>> >>> >>> I am getting current pass: 1, undefined references: NIL, >>> changed-references: NIL >> >> This is not good. >> When the ref id is not yet defined, #'find-ref-point-page-number >> should push >> the missing ref id in *undefined-references*. >> This would start a second pass. >> >> Are you looking at the value of *undefined-references* just before >> the end >> of with-document ? >> (it's cleared at the beginning) >> >> Marc >> > > It seems that I was calling the mark-ref-point too soon (i.e. before > the footer was built). I've appended the code I am using (it is based > on the multi-page example in test.lisp). I added some format > statements to some methods in references.lisp and this is what I'm > getting. I also changed the initform of pagenumber to -1 from 999 so I > could see the difference between the reference point not being defined > and the initform. It seems that the page number is not being changed. > > > find-ref-point 'END-OF-DOC' -- ref-point [NIL]/NIL/NIL > find-ref-point-page-number UNKNOWN ;; this means that there is no > ref-point yet > find-ref-point 'END-OF-DOC' -- ref-point [# 12D4BD43>]/#/NIL > find-ref-point-page-number -1 ;; now there is one, but the page number > is -1 (the initform) > current pass: 1, undefined references: (END-OF-DOC), > changed-references: NIL > find-ref-point 'END-OF-DOC' -- ref-point [# 12D4BD43>]/NIL/# > find-ref-point-page-number -1 > find-ref-point 'END-OF-DOC' -- ref-point [# 11DCA83B>]/#/# 12D4BD43> > find-ref-point-page-number -1 > current pass: 2, undefined references: NIL, changed-references: NIL > WRITE THE DOCUMENT NOW > > After a little more mucking about, it seems that the method stroke ((ref-point ref-point) x y) is not being called. This appears to be where the page number is supposed to be set to the correct value (at least this is the only place that I could find that sets the page number of a ref-point). Cheers, Bob From marc.battyani at fractalconcept.com Thu Sep 30 21:58:58 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Thu, 30 Sep 2004 23:58:58 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: <153c01c4a738$b0717810$0a02a8c0@marcxp> Bob Hutchison wrote: > It seems that I was calling the mark-ref-point too soon (i.e. before > the footer was built). I've appended the code I am using (it is based > on the multi-page example in test.lisp). I added some format statements > to some methods in references.lisp and this is what I'm getting. I also > changed the initform of pagenumber to -1 from 999 so I could see the > difference between the reference point not being defined and the > initform. It seems that the page number is not being changed. No the mark-ref-point was called at the right place because it creates a box that will be instered in the stream of boxes. The place where you call it now is outside a text-content so the box will be nowhere and the ref will not be computed. > (setq content > (compile-text () > (paragraph (:font "Times-Bold" :font-size 16 :top-margin > 20) > "2. Second paragraph group" > (hrule :dy 2)) > (dotimes (i 40) > (paragraph (:font "Times-Roman" :font-size (+ 6 (random > 10))) > (verbatim (format nil "2.~d. " (1+ i))) > (dotimes (j (1+ (random 5))) > (put-string "The quick brown fox jumps over the > lazy dog. ")))) > ;(tt::mark-ref-point :end-of-doc) <-- This won't work > here No this is the right point to put it > )) > (draw-pages content :margins margins :header header :footer > footer)) > (tt::mark-ref-point :end-of-doc) The ref will be nowhere here. The problem is more with #'find-ref-point-page-number Marc From peter at javamonkey.com Thu Sep 30 21:56:16 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 14:56:16 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: (Peter Seibel's message of "Thu, 30 Sep 2004 14:34:44 -0700") References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: Peter Seibel writes: > "Marc Battyani" writes: > >> Bob Hutchison wrote: >>> On Sep 30, 2004, at 4:39 PM, Marc Battyani wrote: >>> >>> > The multipass mechnism is integrated into typeset:with-document so it >>> > should >>> > work in your code. >>> > >>> > As they are several passes you should use: >>> > >>> > (when (typeset::final-pass-p) >>> > (pdf:write-document file)) >>> >>> This doesn't seem to make any difference. I'm not sure what happens if >>> it isn't the final pass? how does the document get written? >>> >>> > >>> > To avoid writing the pdf file during the intermediate passes. >>> > (I will probably redefine write-document in typeset to handle this more >>> > easily.) >>> > >>> > How many passes go you get ? >>> > What are the values of *current-pass* *undefined-references* >>> > *changed-references* ? >>> >>> I am getting current pass: 1, undefined references: NIL, >>> changed-references: NIL >> >> This is not good. When the ref id is not yet defined, >> #'find-ref-point-page-number should push the missing ref id in >> *undefined-references*. This would start a second pass. > > So, it looks like in my case that it's finding the ref-point. It's > just that the page-number slot of the ref point is set to 999 and is > never getting reset. What's supposed to trigger that? Okay, more diggging around and I got it to work. The problem was my call to mark-ref-point was clobbering the old ref. So I changed my call: (typeset:mark-ref-point :the-end) to: (unless (typeset::find-ref-point :the-end) (typeset:mark-ref-point :the-end)) It seems, at the very least, that perhaps this check in mark-ref-point (when (gethash id *reference-table*) (error "Reference ~s redefined" id)) should be written: (when (find-ref-point id) (error "Reference ~s redefined" id)) so it'll look in *previous-reference-table* as well as *reference-table*. That at least would have given me an error. -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Thu Sep 30 22:05:09 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 1 Oct 2004 00:05:09 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp><149101c4a72d$99ef24d0$0a02a8c0@marcxp><70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca><14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: <154a01c4a739$8d8f9bf0$0a02a8c0@marcxp> Peter Seibel wrote: > So, it looks like in my case that it's finding the ref-point. It's > just that the page-number slot of the ref point is set to 999 and is > never getting reset. What's supposed to trigger that? Bob Hutchison wrote: > After a little more mucking about, it seems that the method stroke > ((ref-point ref-point) x y) is not being called. This appears to be > where the page number is supposed to be set to the correct value (at > least this is the only place that I could find that sets the page > number of a ref-point). The ref page number is computed when stroke is applied to the reference box. Here I suspect it's more a find-ref / footer problem. Marc From hutch at recursive.ca Thu Sep 30 22:11:10 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 18:11:10 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <153c01c4a738$b0717810$0a02a8c0@marcxp> References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> <153c01c4a738$b0717810$0a02a8c0@marcxp> Message-ID: On Sep 30, 2004, at 5:58 PM, Marc Battyani wrote: > Bob Hutchison wrote: >> It seems that I was calling the mark-ref-point too soon (i.e. before >> the footer was built). I've appended the code I am using (it is based >> on the multi-page example in test.lisp). I added some format >> statements >> to some methods in references.lisp and this is what I'm getting. I >> also >> changed the initform of pagenumber to -1 from 999 so I could see the >> difference between the reference point not being defined and the >> initform. It seems that the page number is not being changed. > > No the mark-ref-point was called at the right place because it creates > a box > that will be instered in the stream of boxes. > The place where you call it now is outside a text-content so the box > will be > nowhere and the ref will not be computed. > OK, that's where I thought it should go, makes a lot more sense to me. So I put it back, and this is what I get now: find-ref-point 'END-OF-DOC' -- ref-point [#]/#/NIL find-ref-point-page-number -1 STROKE STROKE ref-point # page-number 2 find-ref-point 'END-OF-DOC' -- ref-point [#]/#/NIL find-ref-point-page-number 2 current pass: 1, undefined references: NIL, changed-references: NIL WRITE THE DOCUMENT NOW So stroke is called, this is good. The trouble seems to be that the reference is used twice, the second time it *is* found. This, I'm guessing is hiding the fact that it was missed the first time. (I've reduced my example to a two page document) Cheers, Bob From marc.battyani at fractalconcept.com Thu Sep 30 22:14:01 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 1 Oct 2004 00:14:01 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp><149101c4a72d$99ef24d0$0a02a8c0@marcxp><70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca><14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: <156c01c4a73a$ca59a1b0$0a02a8c0@marcxp> > Peter Seibel writes: > Okay, more diggging around and I got it to work. The problem was my > call to mark-ref-point was clobbering the old ref. So I changed my > call: > > (typeset:mark-ref-point :the-end) > > to: > > (unless (typeset::find-ref-point :the-end) > (typeset:mark-ref-point :the-end)) > > It seems, at the very least, that perhaps this check in mark-ref-point > > (when (gethash id *reference-table*) > (error "Reference ~s redefined" id)) > > should be written: > > (when (find-ref-point id) > (error "Reference ~s redefined" id)) > > so it'll look in *previous-reference-table* as well as > *reference-table*. That at least would have given me an error. No, it's an error to define twice a ref in the same pass, it's not an error to redefine the ref for each pass. It could have been changed between the 2 passes. Marc From peter at javamonkey.com Thu Sep 30 22:20:41 2004 From: peter at javamonkey.com (Peter Seibel) Date: Thu, 30 Sep 2004 15:20:41 -0700 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: <156c01c4a73a$ca59a1b0$0a02a8c0@marcxp> (Marc Battyani's message of "Fri, 1 Oct 2004 00:14:01 +0200") References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> <156c01c4a73a$ca59a1b0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: >> Peter Seibel writes: > >> Okay, more diggging around and I got it to work. The problem was my >> call to mark-ref-point was clobbering the old ref. So I changed my >> call: >> >> (typeset:mark-ref-point :the-end) >> >> to: >> >> (unless (typeset::find-ref-point :the-end) >> (typeset:mark-ref-point :the-end)) >> >> It seems, at the very least, that perhaps this check in mark-ref-point >> >> (when (gethash id *reference-table*) >> (error "Reference ~s redefined" id)) >> >> should be written: >> >> (when (find-ref-point id) >> (error "Reference ~s redefined" id)) >> >> so it'll look in *previous-reference-table* as well as >> *reference-table*. That at least would have given me an error. > > No, it's an error to define twice a ref in the same pass, it's not > an error to redefine the ref for each pass. It could have been > changed between the 2 passes. Okay, that makes sense. So is my workaround the Right Way or a nasty kludge? -Peter -- Peter Seibel peter at javamonkey.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Thu Sep 30 22:25:46 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 1 Oct 2004 00:25:46 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp><149101c4a72d$99ef24d0$0a02a8c0@marcxp><70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca><14da01c4a733$5cb987d0$0a02a8c0@marcxp><153c01c4a738$b0717810$0a02a8c0@marcxp> Message-ID: <157e01c4a73c$6eef4f30$0a02a8c0@marcxp> Bob Hutchison wrote: > So stroke is called, this is good. The trouble seems to be that the > reference is used twice, the second time it *is* found. This, I'm > guessing is hiding the fact that it was missed the first time. (I've > reduced my example to a two page document) Yes, but finding the ref when it is finally here will not remove it from the *undefined references* list. So you should get a second pass. I will look at this tomorow ;-) Cheers, Marc From marc.battyani at fractalconcept.com Thu Sep 30 22:35:04 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 1 Oct 2004 00:35:04 +0200 Subject: [cl-typesetting-devel] Page n of m? References: <142101c4a727$b0585a80$0a02a8c0@marcxp><149101c4a72d$99ef24d0$0a02a8c0@marcxp><70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca><14da01c4a733$5cb987d0$0a02a8c0@marcxp> <156c01c4a73a$ca59a1b0$0a02a8c0@marcxp> Message-ID: <15bc01c4a73d$bb9d2c20$0a02a8c0@marcxp> Peter Seibel writes: > > Okay, that makes sense. So is my workaround the Right Way or a nasty > kludge? You really want to know ? ;-) I will have a deeper look at all this tomorow. (sorry but I'm too tired now...) Marc From hutch at recursive.ca Thu Sep 30 22:48:06 2004 From: hutch at recursive.ca (Bob Hutchison) Date: Thu, 30 Sep 2004 18:48:06 -0400 Subject: [cl-typesetting-devel] Page n of m? In-Reply-To: References: <142101c4a727$b0585a80$0a02a8c0@marcxp> <149101c4a72d$99ef24d0$0a02a8c0@marcxp> <70EB07C2-1323-11D9-985D-000A95728F12@recursive.ca> <14da01c4a733$5cb987d0$0a02a8c0@marcxp> Message-ID: On Sep 30, 2004, at 5:56 PM, Peter Seibel wrote: >> > > Okay, more diggging around and I got it to work. The problem was my > call to mark-ref-point was clobbering the old ref. So I changed my > call: > > (typeset:mark-ref-point :the-end) > > to: > > (unless (typeset::find-ref-point :the-end) > (typeset:mark-ref-point :the-end)) This is the order of things... 1) tt::mark-ref-point is called 2) tt::find-ref-point-page-number is called (for each footer before the last page) 3) tt:stroke on the ref-point is called (when the last page is drawn) 4) tt:find-ref-point-page-number is called (for the last page) 5) done As soon as the mark-ref-point is called we are on the final pass (there are no more undefined references). So there is no way to correct the footers generated in step 2. It looks as though the technique Peter has come up with simply defers the call to mark-ref-point until the second pass, which seems to be equivalent to the first pass where it is known the ref-point will be needed. This will guarantee two passes even when all reference are backward. Cheers, Bob