Next: , Previous: , Up: Quick Start   [Contents][Index]


3.1 Full Source

The complete source code is given below. You can just cut’n paste it in a REPL and it will (should) work. It is also contained in a file called demos/quickstart.lisp in the distribution (along with other demo programs). You can try it out with, e.g., ‘sbcl --script’ in a terminal.

(in-package :cl-user)

(require "asdf")
(asdf:load-system :net.didierverna.focus)
(net.didierverna.focus:nickname-package)


(defpackage :quotation
  (:use :cl)
  (:export :quotation))

(in-package :quotation)

(defun quotation-formatter (stream argument colonp atsignp &rest arguments)
  (declare (ignore colonp atsignp arguments))
  (write-char #\` stream)
  (write-string argument stream)
  (write-char #\' stream))

(let ((table (focus:make-format-table)))
  (focus:with-format-table table
    (focus:set-format-directive #\` :function 'quotation-formatter))

  (defun quotation (who quotation)
    (focus:with-format-table table
      (focus:format t "As ~A would say: ~`.~%" who quotation))))


(in-package :cl-user)

(quotation:quotation "Bugs Bunny" "Errr, what's up Doc?")