From 8cd635d99447f8f5a533f825f40c281f5f434b32 Mon Sep 17 00:00:00 2001 From: Anders Hoff Date: Tue, 11 Jun 2024 17:29:42 +0200 Subject: [PATCH] . --- docs/lqn.md | 22 ++++++++++++++++++++++ src/init.lisp | 4 ++++ src/io.lisp | 2 ++ src/packages.lisp | 4 ++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/lqn.md b/docs/lqn.md index 66e8017..3cd42ba 100644 --- a/docs/lqn.md +++ b/docs/lqn.md @@ -249,6 +249,18 @@ ; t if l is empty; or d ; Source file: /data/x/lqn/src/basic-utils.lisp ``` +``` + ; LQN:EXTSYM? + ; [symbol] + ; + ; EXTSYM? names a compiled function: + ; Lambda-list: (&OPTIONAL (PKG LQN) DEFAULT &AUX + ; (PKG (FIND-PACKAGE PKG))) + ; Derived type: (FUNCTION (&OPTIONAL T T) (VALUES T &OPTIONAL)) + ; Documentation: + ; list external symbols of package + ; Source file: /data/x/lqn/src/init.lisp +``` ``` ; LQN:FILE? ; [symbol] @@ -1018,6 +1030,16 @@ ; s if sym, not kw; or d ; Source file: /data/x/lqn/src/basic-utils.lisp ``` +``` + ; LQN:STDSTR + ; [symbol] + ; + ; STDSTR names a macro: + ; Lambda-list: (BODY) + ; Documentation: + ; trap stdout as string. + ; Source file: /data/x/lqn/src/io.lisp +``` ``` ; LQN:STR! ; [symbol] diff --git a/src/init.lisp b/src/init.lisp index daf2f7d..aedc167 100644 --- a/src/init.lisp +++ b/src/init.lisp @@ -48,6 +48,10 @@ (abbrev mvc multiple-value-call) (abbrev mvl multiple-value-list) (abbrev vpe vector-push-extend) (defmacro vex (v o) `(vpe ,o ,v)) +(defun extsym? (&optional (pkg "LQN") default &aux (pkg (find-package pkg))) + "list external symbols of package" + (if pkg (loop for s being the external-symbols of pkg collect s) default)) + (defmacro λ (&rest rest) `(lambda ,@rest)) (defun internal-path-string (&optional (path "") (pkg :lqn)) (declare (string path)) (namestring (asdf:system-relative-pathname pkg path))) diff --git a/src/io.lisp b/src/io.lisp index 0ab7edf..d95517f 100644 --- a/src/io.lisp +++ b/src/io.lisp @@ -97,6 +97,8 @@ as alists. see ldnload." (format *standard-output* "~&~a~&" ,s*)))))) (defmacro fmt (s &rest rest) "format to string." (if rest `(format nil ,s ,@rest) `(format nil "~a" ,s))) +(defmacro stdstr (body) "trap stdout as string." + `(with-output-to-string (*standard-output*) ,body)) (defun nstr (n &optional (c #\Space)) "str of length n, filled with c" (make-string n :initial-element c)) diff --git a/src/packages.lisp b/src/packages.lisp index 47fcea8..fe148f1 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -3,13 +3,13 @@ (:nicknames #:cl-lqn) (:export #:d? #:v? #:qry #:qrydb #:qryd #:jsnqryf #:qryl #:proc-qry - #:jsnloads #:jsnloadf #:jsnout #:ldnout #:ldnload #:fmt #:out #:jsnstr #:@* #:@get #:?? + #:jsnloads #:jsnloadf #:jsnout #:ldnout #:ldnload #:fmt #:out #:stdstr #:jsnstr #:@* #:@get #:?? #:read? #:some? #:none? #:all? #:empty? #:size? #:is? #:path? #:subdir #:subfiles #:ls #:dir? #:file? #:cwd #:now #:cmd #:some? #:all? #:none? #:cd #:keys? #:new* #:new$ #:cat$ #:cat* #:head #:tail #:apply* #:range #:linspace #:psh* #:pop* #:flatn* #:compct #:flatall* #:flatn$ #:uniq - #:noop #:kv? #:kw? #:ssym? #:msym? #:trim #:sym! #:kw! + #:noop #:kv? #:kw? #:ssym? #:msym? #:trim #:sym! #:kw! #:extsym? #:num!? #:num? #:flt! #:flt!? #:flt? #:int! #:int!? #:int? #:lst? #:lst! #:lst!? #:seq? #:seq!? #:str! #:str? #:str!? #:vec! #:vec? #:vec!? #:ind* #:sel #:seq