dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

example.lisp (972B)


      1 (eval-when (:compile-toplevel :load-toplevel :execute)
      2   (ql:quickload :named-readtables))
      3 
      4 (defpackage #:silly-named-readtables (:use :cl #:named-readtables))
      5 (in-package #:silly-named-readtables)
      6 
      7 (defreadtable :silly-table
      8   (:merge :standard)
      9   (:dispatch-macro-char #\# #\' (lambda (stream char arg)
     10                                   (declare (ignore char arg))
     11                                   (let ((fname (read stream)))
     12                                     (etypecase fname
     13                                       ((or symbol (cons (eql cl:setf) *))
     14                                        `(function ,fname))
     15                                       (cons `(silly-function ,@fname))))))
     16   (:case :upcase))
     17 
     18 (read-from-string "#'foo")           ;; => #'FOO
     19 (read-from-string "#'(foo bar)")     ;; => #'(FOO BLA)
     20 
     21 (in-readtable :silly-table)
     22 
     23 (read-from-string "#'some-function") ;; => #'SOME-FUNCTION
     24 (read-from-string "#'(foo bar)")     ;; => (SILLY-FUNCTION FOO BAR)