add support for lines to default display
[clinton/lisp-on-lines.git] / src / lines.lisp
1 (in-package :lisp-on-lines)
2
3 (defmacro defline (name (specializer &rest layers-and-combination-keywords) &body docstring-and-body)
4 `(progn
5 ,(eval-when
6 (:compile-toplevel :load-toplevel :execute)
7 (unless (fboundp (contextl::get-layered-function-definer-name name))
8 `(define-layered-function ,name (arg)
9 (:method-combination append))))
10 (define-layered-method
11 ,name
12 ,@layers-and-combination-keywords
13 ,@(unless
14 (or (third layers-and-combination-keywords)
15 (and layers-and-combination-keywords
16 (null (cdr layers-and-combination-keywords))))
17 '(APPEND))
18 (,specializer)
19 ,(when (cdr docstring-and-body)
20 (car docstring-and-body))
21
22 ,(or (cdr docstring-and-body) (car docstring-and-body)))))
23
24 (defun line-out (component object &rest args &key (line #'line-in) &allow-other-keys )
25 (apply #'display component object (append args (funcall line object))))
26
27 (defline line-in (thing)
28 '())
29
30
31 (defmacro call-line (from line &rest args)
32 (with-unique-names (lines object)
33 `(multiple-value-bind (,lines ,object)
34 (funcall ,line)
35 (call-display-with-context ,from ,object nil (append ,args ,lines)))))
36