anchor.diff:  (defvar *flickr-api-key* "")
   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  -;; Utilities
  -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  -
  -(defun die (reason)
  -  "Alert and quit"
  -  (print reason)
  -  (quit))
  -
  -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;; Call local command line tools
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   
  
positive.code:   (when (probe-file (svg-gz-file-path))
      (delete-file (svg-gz-file-path))))
  
  (defun paintr ()
    "Do everything."
    (load-current-id)
    (let ((palxml (colr-random-palette)))
      (loop for i from 0 below 12
        until palxml
        do (sleep 10)
        do (setf palxml (colr-random-palette)))
      (when palxml
        (format t "Got palette xml.~%")
        (let ((palname (palette-name palxml))
  	    (paltags (palette-tags palxml))
  	    (palcolours (palette-colours palxml)))
  	(when (not palname)
  	  (format t "Palette XML fail~% ~a~%" palxml))
  	(when (and palname paltags palcolours)
  	  (format t "Parsed palette details.~%")
  	  (format t "Tags - ~a~%" (format-tags paltags))
  	  (let ((photoxml (flickr-photo-tag-search paltags)))
  	    (when photoxml
  	      (format t "Got photo xml.~%")
  	      (let ((photoname (photo-title photoxml))
  		    (photojpegurl (photo-jpeg-url photoxml))
  		    (photoid (photo-id photoxml))
  		    (photouserid (photo-owner-id photoxml)))
  		(when (not photoname)
  		    (format t "Photo XML fail~% ~a~%" photoxml))
  		(when (and photoname photojpegurl photouserid)
  		  (format t "Parsed photo details.~%")
  		  (let ((photouserxml (flickr-person-details photouserid)))
  		    (when photouserxml
  		      (format t "Got photo user xml.~%")
  		      (let ((photousername (person-username photouserxml)))
  			(wget photojpegurl (jpeg-file-path))
  			(format t "Got jpeg.~%")
  			(autotrace (jpeg-file-path) 
  				   (svg-file-path) 
  				   (length palcolours))
  			(format t "Made autotraced svg.~%")
  			(let ((svg-text nil))
  			  (with-open-file (file (svg-file-path))
  			    (setf svg-text (make-string (file-length file)))
  			    (read-sequence svg-text file))
  			  (setf svg-text (fix-svg svg-text))
  			  (setf svg-text (recolour-svg svg-text palcolours))
  			  (format t "Modified svg.~%")
  			  (with-open-file (file (svg-file-path) 
  						:direction :output 
  						:if-exists :supersede)
  			    (write-sequence svg-text file)))
  			(format t "Wrote modified svg.~%")
  			(gzip (svg-file-path))
  			(format t "Gzipped svg.~%")
  			(rename-file (svg-gz-file-path) (svgz-file-path))
  			(format t "Renamed svg file.~%")
  			(save-writeup (description-file-path) palname paltags 
  				      (photo-html-url photoid photouserxml) 
  				      photoname photousername))
  		      (format t "Saved writeup html.~%")
  		      (save-current-id)
  		      (format t "Wrote new current id.~%")))))))))))
    (cleanup)
    (format t "Cleaned up.~%"))
  
  
negative.code: 
  (defun format-tags (tag-list)
    "Format the tags into a comma-separated list"
    (format nil "~{~a~^, ~}" 
  	  (map 'list 
  	       #'cl-who:escape-string  
  	       tag-list)))
  