<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,3 +5,19 @@ dvipdfm.
 The project webpage is at http://common-lisp.net/project/cl-cairo2,
 where you will find the repository, mailing lists, contact information
 etc.
+
+IMPORTANT: as of May 15, 2009, I have removed the global variable
+*context*, and made context the first argument of every function.
+There are several important reasons for this:
+
+- it conforms better to the underlying Cairo bindings
+
+- it is more Lispy
+
+- having a global variable for the default context didn't make much
+  sense in retrospect
+
+Now the context argument comes FIRST.
+
+I apologize if this inconvenienced anyone, but I had to do it
+sometime, better now than later.  Tamas</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -83,8 +83,18 @@
 
 (cl:defconstant CAIRO_HAS_PS_SURFACE 1)
 
+(cl:defconstant CAIRO_HAS_FT_FONT 1)
+
+(cl:defconstant CAIRO_HAS_DIRECTFB_SURFACE 1)
+
 (cl:defconstant CAIRO_HAS_PNG_FUNCTIONS 1)
 
+(cl:defconstant CAIRO_HAS_XCB_SURFACE 1)
+
+(cl:defconstant CAIRO_HAS_XLIB_XRENDER_SURFACE 1)
+
+(cl:defconstant CAIRO_HAS_XLIB_SURFACE 1)
+
 (cl:defconstant CAIRO_FORMAT_RGB16_565 4)
 
 (cffi:defcfun (&quot;cairo_version&quot; cairo_version) :int)</diff>
      <filename>cl-cairo2-swig.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 
 (defsystem cl-cairo2
   :description &quot;Cairo 1.6 bindings&quot;
-  :version &quot;0.4&quot;
+  :version &quot;0.5&quot;
   :author &quot;Tamas K Papp&quot;
   :license &quot;GPL&quot;
   :components ((:file &quot;package&quot;)</diff>
      <filename>cl-cairo2.asd</filename>
    </modified>
    <modified>
      <diff>@@ -92,18 +92,18 @@ nonlocal exits.&quot;
 ;;;; default context and convenience macros 
 ;;;;
 
-(defvar *context* nil &quot;default cairo context&quot;)
-
-(defmacro with-png-file ((filename format width height &amp;optional (surface-name (gensym))) &amp;body body)
+(defmacro with-png-file ((context filename format width height 
+				  &amp;optional (surface-name (gensym))) &amp;body body)
   &quot;Execute the body with context bound to a newly created png
    file, and close it after executing body.&quot;
-  `(let* ((,surface-name (create-image-surface ,format ,width ,height))
-		  (*context* (create-context ,surface-name)))
-	 (unwind-protect (progn ,@body)
-	   (progn
-		 (surface-write-to-png ,surface-name ,filename)
-		 (destroy *context*)
-		 (destroy ,surface-name)))))
+  (once-only (context)
+    `(let* ((,surface-name (create-image-surface ,format ,width ,height))
+	    (,context (create-context ,surface-name)))
+       (unwind-protect (progn ,@body)
+	 (progn
+	   (surface-write-to-png ,surface-name ,filename)
+	   (destroy ,context)
+	   (destroy ,surface-name))))))
 
 (defmacro with-context ((context pointer) &amp;body body)
   &quot;Execute body with pointer pointing to context, and check status.&quot;
@@ -119,18 +119,18 @@ nonlocal exits.&quot;
 	   (warn &quot;context is not alive&quot;)))))
 
 (defmacro define-with-default-context (name &amp;rest args)
-  &quot;Define cairo function with *context* as its first argument and
+  &quot;Define cairo function with context as its first argument and
   args as the rest, automatically mapping name to the appropriate
   cairo function.&quot;
-  `(defun ,name (,@args &amp;optional (context *context*))
+  `(defun ,name (context ,@args)
      (with-context (context pointer)
        (,(prepend-intern &quot;cairo_&quot; name) pointer ,@args))))
 
 (defmacro define-with-default-context-sync (name &amp;rest args)
-  &quot;Define cairo function with *context* as its first argument and
+  &quot;Define cairo function with context as its first argument and
   args as the rest, automatically mapping name to the appropriate
   cairo function.  sync will be called after the operation.&quot;
-  `(defun ,name (,@args &amp;optional (context *context*))
+  `(defun ,name (context ,@args)
      (with-context (context pointer)
        (,(prepend-intern &quot;cairo_&quot; name) pointer ,@args))
      (sync context)))
@@ -138,7 +138,7 @@ nonlocal exits.&quot;
 (defmacro define-flexible ((name pointer &amp;rest args) &amp;body body)
   &quot;Like define-with-default context, but with arbitrary body,
   pointer will point to the context.&quot;
-  `(defun ,name (,@args &amp;optional (context *context*))
+  `(defun ,name (context ,@args)
      (with-context (context ,pointer)
        ,@body)))
 
@@ -195,7 +195,7 @@ nonlocal exits.&quot;
 (define-with-default-context-sync stroke)
 (define-with-default-context-sync stroke-preserve)
 
-(defun set-source-surface (image x y &amp;optional (context *context*))
+(defun set-source-surface (context image x y)
   (with-alive-object (image i-pointer)
 	(with-context (context c-pointer)
 	  (cairo_set_source_surface c-pointer i-pointer x y))))
@@ -212,17 +212,17 @@ will be nil, as cairo can't provide that in general.&quot;
 ;;;; set colors using the cl-colors library
 ;;;;
 
-(defgeneric set-source-color (color &amp;optional context))
+(defgeneric set-source-color (context color))
 
-(defmethod set-source-color ((color rgb) &amp;optional (context *context*))
+(defmethod set-source-color (context (color rgb))
   (with-slots (red green blue) color
     (set-source-rgb red green blue context)))
 
-(defmethod set-source-color ((color rgba) &amp;optional (context *context*))
+(defmethod set-source-color (context (color rgba))
   (with-slots (red green blue alpha) color
     (set-source-rgba red green blue alpha context)))
 
-(defmethod set-source-color ((color hsv) &amp;optional (context *context*))
+(defmethod set-source-color (context (color hsv))
   (with-slots (red green blue) (hsv-&gt;rgb color)
     (set-source-rgb red green blue context)))
 </diff>
      <filename>context.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -22,15 +22,15 @@
    ;; context
     
    context with-png-file create-context sync sync-lock sync
-   sync-unlock sync-reset with-sync-lock *context* save restore
-   push-group pop-group pop-group-to-source set-source-rgb
-   set-source-rgba clip clip-preserve reset-clip copy-page show-page
-   fill-preserve paint paint-with-alpha stroke stroke-preserve
-   set-source-color get-line-width set-line-width get-miter-limit
-   set-miter-limit get-antialias set-antialias get-fill-rule
-   set-fill-rule get-line-cap set-line-cap get-line-join set-line-join
-   get-operator set-operator fill-path set-dash get-dash clip-extents
-   fill-extents in-fill in-stoke create-ps-context create-pdf-context
+   sync-unlock sync-reset with-sync-lock save restore push-group
+   pop-group pop-group-to-source set-source-rgb set-source-rgba clip
+   clip-preserve reset-clip copy-page show-page fill-preserve paint
+   paint-with-alpha stroke stroke-preserve set-source-color
+   get-line-width set-line-width get-miter-limit set-miter-limit
+   get-antialias set-antialias get-fill-rule set-fill-rule
+   get-line-cap set-line-cap get-line-join set-line-join get-operator
+   set-operator fill-path set-dash get-dash clip-extents fill-extents
+   in-fill in-stoke create-ps-context create-pdf-context
    create-svg-context get-target set-source-surface
 
    ;;pattern</diff>
      <filename>package.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -181,4 +181,5 @@ and then execute body in which the patterns can be referenced using the names.&quot;
 	  `(let ,(loop for f in pattern-forms collect `(,(car f) ,(cadr f)))
 		 (unwind-protect (progn ,@body)
 		   (progn
-			 ,@(loop for f in pattern-forms collect `(destroy ,(car f))))))))
+			 ,@(loop for f in pattern-forms collect
+				`(destroy ,(car f))))))))</diff>
      <filename>pattern.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,8 @@
-EXAMPLEFILES=hearts.png lissajous.eps text.eps example.eps pattern.eps
-RAWEXAMPLEFILES=hearts.png lissajous.pdf text.pdf example.pdf pattern.pdf
+EXAMPLEFILES=hearts.pdf lissajous.pdf text.pdf example.pdf pattern.pdf
 LISP=sbcl
 
-tutorial.pdf: tutorial.dvi
-	dvipdfm tutorial
+tutorial.pdf: tutorial.tex $(EXAMPLEFILES)
+	pdflatex tutorial.tex
 
-tutorial.dvi: tutorial.tex $(EXAMPLEFILES)
-	latex tutorial.tex
-
-$(RAWEXAMPLEFILES): example.lisp
+$(EXAMPLEFILES): example.lisp
 	$(LISP) --eval '(progn (load &quot;example.lisp&quot;) (quit))'
-
-%.eps: %.pdf
-	pdf2ps $&lt; $@</diff>
      <filename>tutorial/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -12,17 +12,17 @@
 ;;;;
 
 (defparameter *surface* (create-pdf-surface &quot;example.pdf&quot; 200 100))
-(setf *context* (create-context *surface*))
+(defparameter *context* (create-context *surface*))
 (destroy *surface*)
 ;; clear the whole canvas with blue
-(set-source-rgb 0.2 0.2 1)
-(paint)
+(set-source-rgb *context* 0.2 0.2 1)
+(paint *context*)
 ;; draw a white diagonal line
-(move-to 200 0)
-(line-to 0 100)
-(set-source-rgb 1 1 1)
-(set-line-width 5)
-(stroke)
+(move-to *context* 200 0)
+(line-to *context* 0 100)
+(set-source-rgb *context* 1 1 1)
+(set-line-width *context* 5)
+(stroke *context*)
 ;; destroy context, this also destroys the surface and closes the file
 (destroy *context*)
 
@@ -30,21 +30,19 @@
 ;;;; helper functions
 ;;;;
 
-(defun show-text-aligned (text x y &amp;optional (x-align 0.5) (y-align 0.5)
-			  (context *context*))
+(defun show-text-aligned (context text x y &amp;optional (x-align 0.5) (y-align 0.5))
   &quot;Show text aligned relative to (x,y).&quot;
-  (let ((*context* context))
-    (multiple-value-bind (x-bearing y-bearing width height)
-	(text-extents text)
-      (move-to (- x (* width x-align) x-bearing)
-	       (- y (* height y-align) y-bearing))
-      (show-text text))))
+  (multiple-value-bind (x-bearing y-bearing width height)
+      (text-extents context text)
+    (move-to context (- x (* width x-align) x-bearing)
+	     (- y (* height y-align) y-bearing))
+    (show-text context text)))
 
 ;;;; very simple text example
-(setf *context* (create-pdf-context &quot;simpletext.pdf&quot; 100 100))
-(move-to 0 100)
-(set-font-size 50)
-(show-text &quot;foo&quot;)
+(defparameter *context* (create-pdf-context &quot;simpletext.pdf&quot; 100 100))
+(move-to *context* 0 100)
+(set-font-size *context* 50)
+(show-text *context* &quot;foo&quot;)
 (destroy *context*)
 
 
@@ -54,18 +52,18 @@
 ;;;;  This example demonstrates the use of text-extents, by placing
 ;;;;  text aligned relative to a red marker.
 
-(defun mark-at (x y d red green blue)
+(defun mark-at (context x y d red green blue)
   &quot;Make a rectangle of size 2d around x y with the given colors,
   50% alpha.  Used for marking points.&quot;
-  (rectangle (- x d) (- y d) (* 2 d) (* 2 d))
-  (set-source-rgba red green blue 0.5)
-  (fill-path))
+  (rectangle context (- x d) (- y d) (* 2 d) (* 2 d))
+  (set-source-rgba context red green blue 0.5)
+  (fill-path context))
 
-(defun show-text-with-marker (text x y x-align y-align)
+(defun show-text-with-marker (context text x y x-align y-align)
   &quot;Show text aligned relative to a red market at (x,y).&quot;
-  (mark-at x y 2 1 0 0)
-  (set-source-rgba 0 0 0 0.6)
-  (show-text-aligned text x y x-align y-align))
+  (mark-at context x y 2 1 0 0)
+  (set-source-rgba context 0 0 0 0.6)
+  (show-text-aligned context text x y x-align y-align))
 
 (defparameter width 500)
 (defparameter height 500)
@@ -73,109 +71,40 @@
 (defparameter size 50)
 (defparameter x 20d0)
 (defparameter y 50d0)
-(setf *context* (create-pdf-context &quot;text.pdf&quot; width height))
+(defparameter *context* (create-pdf-context &quot;text.pdf&quot; width height))
 ;;(setf *context* (create-svg-context &quot;text.svg&quot; width height))
 ;;(setf *context* (create-pdf-context &quot;text.pdf&quot; width height))
 ;; white background
-(set-source-rgb 1 1 1)
-(paint)
+(set-source-rgb *context* 1 1 1)
+(paint *context*)
 ;; setup font
-(select-font-face &quot;Arial&quot; :normal :normal)
-(set-font-size size)
+(select-font-face *context* &quot;Arial&quot; :normal :normal)
+(set-font-size *context* size)
 ;; starting point
-(mark-at x y 2 1 0 0)			; red
+(mark-at *context* x y 2 1 0 0)		; red
 ;; first text in a box
 (multiple-value-bind (x-bearing y-bearing text-width text-height)
-    (text-extents text)
+    (text-extents *context* text)
   (let ((rect-x (+ x x-bearing))
 	(rect-y (+ y y-bearing)))
-    (rectangle rect-x rect-y text-width text-height)
-    (set-source-rgba 0 0 1 0.3)		; blue
-    (set-line-width 1)
-    (set-dash 0 '(5 5))
-    (stroke)))
-(set-source-rgba 0 0 0 0.6)
-(move-to x y)
-(show-text text)
-;; text automatically aligned
-;; (dolist (x-align '(0 0.5 1))
-;;   (dolist (y-align '(0 0.5 1))
-;;     (show-text-with-marker text (+ x (* x-align 300)) (+ y (* y-align 300) 100)
-;; 			   x-align y-align)))
-(dolist (x-align '(0))
-  (dolist (y-align '(0))
-    (show-text-with-marker text (+ x (* x-align 300)) (+ y (* y-align 300) 100)
-			   x-align y-align)))
-
-(show-text-with-marker text x (+ y 100d0) 0d0 0d0)
-;; done
-(destroy *context*)
-
-
-
-;;;;
-;;;;  text placement example
-;;;;
-;;;;  This example demonstrates the use of text-extents, by placing
-;;;;  text aligned relative to a red marker.
-
-(defun mark-at (x y d red green blue)
-  &quot;Make a rectangle of size 2d around x y with the given colors,
-  50% alpha.  Used for marking points.&quot;
-  (rectangle (- x d) (- y d) (* 2 d) (* 2 d))
-  (set-source-rgba red green blue 0.5)
-  (fill-path))
-
-(defun show-text-with-marker (text x y x-align y-align)
-  &quot;Show text aligned relative to a red market at (x,y).&quot;
-  (mark-at x y 2 1 0 0)
-  (set-source-rgba 0 0 0 0.6)
-  (show-text-aligned text x y x-align y-align))
-
-(defparameter width 500)
-(defparameter height 500)
-(defparameter text &quot;Fog&quot;)		; contains g, which goes below baseline
-(defparameter size 50)
-(defparameter x 20)
-(defparameter y 50)
-(setf *context* (create-pdf-context &quot;text2.pdf&quot; width height))
-;;(setf *context* (create-svg-context &quot;text.svg&quot; width height))
-;;(setf *context* (create-pdf-context &quot;text.pdf&quot; width height))
-;; white background
-(set-source-rgb 1 1 1)
-(paint)
-;; setup font
-(select-font-face &quot;Arial&quot; :normal :normal)
-(set-font-size size)
-;; starting point
-(mark-at x y 2 1 0 0)			; red
-;; first text in a box
-(multiple-value-bind (x-bearing y-bearing text-width text-height)
-    (text-extents text)
-  (let ((rect-x (+ x x-bearing))
-	(rect-y (+ y y-bearing)))
-    (rectangle rect-x rect-y text-width text-height)
-    (set-source-rgba 0 0 1 0.3)		; blue
-    (set-line-width 1)
-    (set-dash 0 '(5 5))
-    (stroke)))
-(set-source-rgba 0 0 0 0.6)
-(move-to x y)
-(show-text text)
-;; text automatically aligned
+    (rectangle *context* rect-x rect-y text-width text-height)
+    (set-source-rgba *context* 0 0 1 0.3)		; blue
+    (set-line-width *context* 1)
+    (set-dash *context* 0 '(5 5))
+    (stroke *context*)))
+(set-source-rgba *context* 0 0 0 0.6)
+(move-to *context* x y)
+(show-text *context* text)
 (dolist (x-align '(0 0.5 1))
   (dolist (y-align '(0 0.5 1))
-    (show-text-with-marker text
-			   (+ x (* x-align 300))
+    (show-text-with-marker *context* text (+ x (* x-align 300))
 			   (+ y (* y-align 300) 100)
 			   x-align y-align)))
-
-;(show-text-with-marker text (+ x 0) (+ y 0 0) 0 0)
-
 ;; done
 (destroy *context*)
 
 
+
 ;;;;
 ;;;;  Lissajous curves
 ;;;;
@@ -188,26 +117,26 @@
 (defparameter density 2000)
 (setf *context* (create-pdf-context &quot;lissajous.pdf&quot; size size))
 ;; pastel blue background
-(rectangle 0 0 width height)
-(set-source-rgb 0.9 0.9 1)
-(fill-path)
+(rectangle *context* 0 0 width height)
+(set-source-rgb *context* 0.9 0.9 1)
+(fill-path *context*)
 ;; Lissajous curves, blue
 (labels ((stretch (x) (+ (* (1+ x) (- (/ size 2) margin)) margin)))
-  (move-to (stretch (sin delta)) (stretch 0))
+  (move-to *context* (stretch (sin delta)) (stretch 0))
   (dotimes (i density)
     (let* ((v (/ (* i pi 2) density))
 	   (x (sin (+ (* a v) delta)))
 	   (y (sin (* b v))))
-      (line-to (stretch x) (stretch y)))))
-(close-path)
-(set-line-width .5)
-(set-source-rgb 0 0 1)
-(stroke)
+      (line-to *context* (stretch x) (stretch y)))))
+(close-path *context*)
+(set-line-width *context* .5)
+(set-source-rgb *context* 0 0 1)
+(stroke *context*)
 ;; &quot;cl-cairo2&quot; in Arial bold to the center
-(select-font-face &quot;Arial&quot; :normal :bold)
-(set-font-size 100)
-(set-source-rgba 1 0.75 0 0.5)		; orange
-(show-text-aligned &quot;cl-cairo2&quot; (/ size 2) (/ size 2))
+(select-font-face *context* &quot;Arial&quot; :normal :bold)
+(set-font-size *context* 100)
+(set-source-rgba *context* 1 0.75 0 0.5)		; orange
+(show-text-aligned *context* &quot;cl-cairo2&quot; (/ size 2) (/ size 2))
 ;; done
 (destroy *context*)
 
@@ -219,34 +148,37 @@
 ;;;;  Rotation, translation and scaling is achieved using the
 ;;;;  appropriate cairo functions.
 
-(defun heart (alpha)
+(defun heart (context alpha)
   &quot;Draw a heart with fixed size and the given transparency alpha.
   Heart is upside down.&quot;
   (let ((radius (sqrt 0.5)))
-    (move-to 0 -2)
-    (line-to 1 -1)
-    (arc 0.5 -0.5 radius (deg-to-rad -45) (deg-to-rad 135))
-    (arc -0.5 -0.5 radius (deg-to-rad 45) (deg-to-rad 215))
-    (close-path)
-    (set-source-rgba 1 0 0 alpha)
-    (fill-path)))
+    (move-to context 0 -2)
+    (line-to context 1 -1)
+    (arc context 0.5 -0.5 radius (deg-to-rad -45) (deg-to-rad 135))
+    (arc context -0.5 -0.5 radius (deg-to-rad 45) (deg-to-rad 215))
+    (close-path context)
+    (set-source-rgba context 1 0 0 alpha)
+    (fill-path context)))
 
 (defparameter width 1024)
 (defparameter height 768)
 (defparameter max-angle 40d0)
-(with-png-file (&quot;hearts.png&quot; :rgb24 width height)
-  ;; fill with white
-  (rectangle 0 0 width height)
-  (set-source-rgb 1 1 1)
-  (fill-path)
-  ;; draw the hearts
-  (dotimes (i 200)
-     (let ((scaling (+ 5d0 (random 40d0))))
-       (reset-trans-matrix)			  ; reset matrix
-       (translate (random width) (random height)) ; move the origin
-       (scale scaling scaling)			  ; scale
-       (rotate (deg-to-rad (- (random (* 2 max-angle)) max-angle 180))) ; rotate
-       (heart (+ 0.1 (random 0.7))))))
+;(with-png-file 
+(defparameter *context* (create-pdf-context &quot;hearts.pdf&quot; width height))
+;; fill with white
+(rectangle *context* 0 0 width height)
+(set-source-rgb *context* 1 1 1)
+(fill-path *context*)
+;; draw the hearts
+(dotimes (i 200)
+  (let ((scaling (+ 5d0 (random 40d0))))
+    (reset-trans-matrix *context*)	; reset matrix
+    (translate *context* (random width) (random height)) ; move the origin
+    (scale *context* scaling scaling)		    ; scale
+    (rotate *context* (deg-to-rad (- (random (* 2 max-angle))
+				     max-angle 180))) ; rotate
+    (heart *context* (+ 0.1 (random 0.7)))))
+(destroy *context*)
 
 ;;;;
 ;;;; make a rainbow-like pattern
@@ -255,7 +187,7 @@
 
 (defparameter width 100)
 (defparameter height 40)
-(setf *context* (create-pdf-context &quot;pattern.pdf&quot; width height))
+(defparameter *context* (create-pdf-context &quot;pattern.pdf&quot; width height))
 (with-linear-pattern rainbow (0 0 width 0)
     `((0   (0.7 0 0.7 0))      ;rgb(a) color as list
       (1/6 ,cl-colors:+blue+)  ;color as cl-color
@@ -264,7 +196,7 @@
       (4/6 ,cl-colors:+orange+)
       (5/6 ,cl-colors:+red+)
       (1   ,cl-colors:+violetred+))
-  (rectangle 0 0 width height)
-  (set-source rainbow)
-  (fill-path))
+  (rectangle *context* 0 0 width height)
+  (set-source *context* rainbow)
+  (fill-path *context*))
 (destroy *context*)</diff>
      <filename>tutorial/example.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -11,8 +11,6 @@
 \global \let \hyper@last\relax 
 \fi
 
-\providecommand*\HyPL@Entry[1]{}
-\HyPL@Entry{0 &lt;&lt; /S /D &gt;&gt; }
 \@writefile{toc}{\contentsline {section}{\numberline {1}Introduction}{1}{section.1}}
 \newlabel{sec:introduction}{{1}{1}{Introduction\relax }{section.1}{}}
 \@writefile{toc}{\contentsline {section}{\numberline {2}Installation and loading}{2}{section.2}}
@@ -29,12 +27,12 @@
 \newlabel{sec:general}{{4.1}{4}{General\relax }{subsection.4.1}{}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Surfaces}{4}{subsection.4.2}}
 \newlabel{sec:surfaces}{{4.2}{4}{Surfaces\relax }{subsection.4.2}{}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Contexts}{5}{subsection.4.3}}
-\newlabel{sec:contexts}{{4.3}{5}{Contexts\relax }{subsection.4.3}{}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Contexts}{4}{subsection.4.3}}
+\newlabel{sec:contexts}{{4.3}{4}{Contexts\relax }{subsection.4.3}{}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.4}Paths}{5}{subsection.4.4}}
 \newlabel{sec:paths}{{4.4}{5}{Paths\relax }{subsection.4.4}{}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {4.5}Text}{6}{subsection.4.5}}
-\newlabel{sec:text}{{4.5}{6}{Text\relax }{subsection.4.5}{}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {4.5}Text}{5}{subsection.4.5}}
+\newlabel{sec:text}{{4.5}{5}{Text\relax }{subsection.4.5}{}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.6}Transformations}{6}{subsection.4.6}}
 \newlabel{sec:transformations}{{4.6}{6}{Transformations\relax }{subsection.4.6}{}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.7}Xlib Contexts}{6}{subsection.4.7}}
@@ -43,14 +41,14 @@
 \newlabel{sec:ms-windows-contexts}{{4.8}{7}{MS-Windows contexts\relax }{subsection.4.8}{}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.9}To Do}{7}{subsection.4.9}}
 \newlabel{sec:todo}{{4.9}{7}{To Do\relax }{subsection.4.9}{}}
-\@writefile{toc}{\contentsline {section}{\numberline {5}Examples}{8}{section.5}}
-\newlabel{sec:examples}{{5}{8}{Examples\relax }{section.5}{}}
-\@writefile{lol}{\contentsline {lstlisting}{example.lisp}{8}{lstlisting.-8}}
-\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces text.ps}}{15}{figure.2}}
-\newlabel{fig:text}{{2}{15}{text.ps\relax }{figure.2}{}}
-\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces lissajous.ps}}{16}{figure.3}}
-\newlabel{fig:lissajous}{{3}{16}{lissajous.ps\relax }{figure.3}{}}
-\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces hearts.png}}{16}{figure.4}}
-\newlabel{fig:hearts}{{4}{16}{hearts.png\relax }{figure.4}{}}
-\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces pattern.ps}}{17}{figure.5}}
-\newlabel{fig:pattern}{{5}{17}{pattern.ps\relax }{figure.5}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {5}Examples}{7}{section.5}}
+\newlabel{sec:examples}{{5}{7}{Examples\relax }{section.5}{}}
+\@writefile{lol}{\contentsline {lstlisting}{example.lisp}{7}{lstlisting.-8}}
+\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces text.pdf}}{13}{figure.2}}
+\newlabel{fig:text}{{2}{13}{text.pdf\relax }{figure.2}{}}
+\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces lissajous.pdf}}{14}{figure.3}}
+\newlabel{fig:lissajous}{{3}{14}{lissajous.pdf\relax }{figure.3}{}}
+\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces hearts.pdf}}{14}{figure.4}}
+\newlabel{fig:hearts}{{4}{14}{hearts.pdf\relax }{figure.4}{}}
+\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces pattern.pdf}}{15}{figure.5}}
+\newlabel{fig:pattern}{{5}{15}{pattern.pdf\relax }{figure.5}{}}</diff>
      <filename>tutorial/tutorial.aux</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>tutorial/tutorial.pdf</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-\documentclass[12pt,letterpaper,dvipdfm]{article}
+\documentclass[12pt,letterpaper]{article}
 
 % \usepackage{amsmath}
 % \usepackage{amsfonts}
@@ -116,16 +116,15 @@ you build a path (which you want to fill with a color/pattern, stroke
 with a given line style, or even save), all of this happens in a
 context.
 
-All \verb!cl-cairo2! functions that use a context take it as
-their last optional argument.  If not given, these functions use
-\lstinline!*context*!, a special variable that stores the default
-context.
-
-Contexts are created from \emph{surfaces} --- which, at this point,
-should be thought of as the bare canvas itself (think of PDF,
-PostScript, of PNG files). All
-Cairo objects, including contexts and surfaces, are implemented in
-CLOS wrappers, and can be closed (\emph{destroyed}) with
+All \verb!cl-cairo2! functions that use a context take it as their
+first argument.\footnote{This is a change from previous versions of
+  \texttt{cl-cairo2}, where the context was the last argument, it was
+  optional and the default was stored in a global variable.  Believe
+  me, that was a huge wart.}  Contexts are created from
+\emph{surfaces} --- which, at this point, should be thought of as the
+bare canvas itself (think of PDF, PostScript, of PNG files). All Cairo
+objects, including contexts and surfaces, are implemented in CLOS
+wrappers, and can be closed (\emph{destroyed}) with
 \lstinline!destroy!.
 
 When the context is created from a surface, the reference count (in
@@ -142,7 +141,7 @@ result is shown in Figure~\ref{fig:example}.
 
 \begin{figure}[htbp]
   \centering
-  \includegraphics{example.eps}
+  \includegraphics{example.pdf}
   \caption{white diagonal line on a blue background}
   \label{fig:example}
 \end{figure}
@@ -152,7 +151,7 @@ the \lstinline!create-*-context! convenience commands provided by
 cl-cairo2.  For example, the first three lines of the code above would
 be replaced by
 \begin{lstlisting}
-(setf *context* (create-ps-context &quot;example.ps&quot; 200 100))
+(defparameter *context* (create-ps-context &quot;example.ps&quot; 200 100))
 \end{lstlisting}
 Unlike the original Cairo API, surfaces and contexts in
 \lstinline!cl-cairo2! remember their width and height.  Use the
@@ -176,9 +175,9 @@ package map these to the enum constants used by Cairo.  cl-cairo2 uses
 lookup tables (assoc lists) for this purpose, which are defined in
 \verb!tables.lisp!.  Cairo constants
 \texttt{CAIRO\_\textsl{PROPERTY}\_\textsl{SOMETHING}} usually map to
-the Lisp symbol \lstinline!property-something!, and can only be used
-in setting or querying \texttt{PROPERTY}.  For example,
-\verb!CAIRO_FORMAT_RGB24!  is mapped to \lstinline!format-rgb24!, and
+the Lisp keyword symbol \lstinline!:property-something!, and can only
+be used in setting or querying \texttt{PROPERTY}.  For example,
+\verb!CAIRO_FORMAT_RGB24!  is mapped to \lstinline!:format-rgb24!, and
 using it for some other property will create an error.
 
 Likewise, names of the Lisp function are easy to deduce from the name
@@ -244,9 +243,7 @@ package for that.
 
 Contexts are represented as the class \lstinline!context!, which
 currently only has one slot, a pointer to the context.  When contexts
-are destroyed, this is set to \lstinline!nil!.  As mentioned above,
-the default context is \lstinline!*context*!, and it is the default
-for the last (optional) argument of each function.
+are destroyed, this is set to \lstinline!nil!.
 
 The macro \lstinline!with-context! is similar to
 \lstinline!with-surface! above (it executes the body with pointer
@@ -430,29 +427,29 @@ the results.
 
 \begin{figure}[htbp]
   \centering
-  \includegraphics[height=8cm]{text.eps}
-  \caption{text.ps}
+  \includegraphics[height=8cm]{text.pdf}
+  \caption{text.pdf}
   \label{fig:text}
 \end{figure}
 
 \begin{figure}[htbp]
   \centering
-  \includegraphics[height=8cm]{lissajous.eps}
-  \caption{lissajous.ps}
+  \includegraphics[height=8cm]{lissajous.pdf}
+  \caption{lissajous.pdf}
   \label{fig:lissajous}
 \end{figure}
 
 \begin{figure}[htbp]
   \centering
-  \includegraphics[natwidth=12cm, natheight=9cm]{hearts.png}
-  \caption{hearts.png}
+  \includegraphics[height=8cm]{hearts.pdf}
+  \caption{hearts.pdf}
   \label{fig:hearts}
 \end{figure}
 
 \begin{figure}[htbp]
   \centering
-  \includegraphics[height=4cm]{pattern.eps}
-  \caption{pattern.ps}
+  \includegraphics[height=4cm]{pattern.pdf}
+  \caption{pattern.pdf}
   \label{fig:pattern}
 \end{figure}
 </diff>
      <filename>tutorial/tutorial.tex</filename>
    </modified>
    <modified>
      <diff>@@ -47,12 +47,16 @@
 		nil
 		image-surface)))
 
-(defmacro with-win32-context ((hwnd hdc width height &amp;optional (surface-name (gensym))) &amp;body body)
-  `(multiple-value-bind (,surface-name ,width ,height) (win32-create-surface ,hwnd ,hdc)
-	 (let ((*context* (create-context ,surface-name)))
+(defmacro with-win32-context ((context hwnd hdc width height 
+				       &amp;optional (surface-name (gensym)))
+			      &amp;body body)
+  (once-only (context)
+    `(multiple-value-bind (,surface-name ,width ,height)
+	 (win32-create-surface ,hwnd ,hdc)
+	 (let ((,context (create-context ,surface-name)))
 	   (unwind-protect (progn ,@body)
 		 (progn
-		   (destroy *context*)
+		   (destroy ,context)
 		   (destroy ,surface-name))))))
 
 ;;;</diff>
      <filename>win32.lisp</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>tutorial/flowers.png</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>4cb781d94e502452cc06399c70fa537fc1a09048</id>
    </parent>
  </parents>
  <author>
    <name>tpapp</name>
    <email>tkpapp@gmail.com</email>
  </author>
  <url>http://github.com/tpapp/cl-cairo2/commit/9b0a4c46b78528a45fafd543a2dddc032e709ce6</url>
  <id>9b0a4c46b78528a45fafd543a2dddc032e709ce6</id>
  <committed-date>2009-05-15T18:35:20-07:00</committed-date>
  <authored-date>2009-05-15T18:35:20-07:00</authored-date>
  <message>Eliminated *context*, now context is the first argument in functions
that use it.

Cleanup of documentation and tutorial generation.</message>
  <tree>b437663dafa99bbf519f965ad8a7b4bf58e7a6ac</tree>
  <committer>
    <name>tpapp</name>
    <email>tkpapp@gmail.com</email>
  </committer>
</commit>
