Skip to content

Commit

Permalink
handle special (vprogn) symbols in veq (in example script)
Browse files Browse the repository at this point in the history
  • Loading branch information
inconvergent committed Jul 27, 2024
1 parent 72df650 commit 247225a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
16 changes: 12 additions & 4 deletions bin/search-symbols.lisp
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
(in-package :lqn)

(let ((q (second (cmd-args))) (pkg (third (cmd-args))))
(qry (ls "~/common-lisp/*/src/packages.lisp")
(block main
(let ((q (second (cmd-args)))
(pkg (third (cmd-args)))
(veq-symbs (vec! veq::*docstring-map*)))
(labels ((veq-special (s &aux (res (and (equal "VEQ" (package-name (symbol-package s)))
(second (find s veq-symbs :key #'car)))))
(when res (str! "veq:" s " (vprogn)" #\Newline res))))
(unless q (return-from main))
(qry (ls "~/common-lisp/*/src/packages.lisp")
dat-read-file _@flatn* second ; package names
[(or (not pkg) (isub? s@_ pkg))] extsym? _@flatn* ; filter packages
[(or (string= s@q "_") (isub? s@_ q))] ; filter symbol ; _ matches all
#((join (head (splt (stdstr _@describe)
#((join (head (splt (or (veq-special _)
(stdstr _@describe))
#.(str! #\Newline) nil) -1) ; some formatting
#\Newline ";; ")
(out "~&~&██ ~a~&~%" _))))
(out "~&~&██ ~a~&~%" _))))))

3 changes: 2 additions & 1 deletion src/basic-utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
(defun psymb (&optional (pkg 'lqn) &rest args) ;https://gist.github.com/lispm/6ed292af4118077b140df5d1012ca646
"mkstr, make symbol in pkg."
(values (intern (sup (apply #'mkstr args)) pkg)))
(defun lst (&rest rest) (apply #'list rest))
(defun lst (&rest rest) (apply #'list rest)) ; TODO: this collides with eg. veq:lst. check packages when overriding with internal symbol?

(defmacro car- (fx d) (declare (symbol d)) `(and (listp ,d) (,fx (car ,d))))
(defun sym-mode? (d &aux (mode-sym (unpack-mode d nil)))
(if mode-sym (values-list (unpack-mode mode-sym d :?)) (values nil d)))
(defun qop? (s d &aux (d (and (listp d) (car d)))) (and d (ssym? d) (eq s (kw d))))
(defun dat? (d) (and (symbolp d) (eq (kw d) :_)))
; TODO: make this test better to avoid eg. veq:lst collision
(defun lqnfx? (d) (and (ssym? d) (member (kw d) *fxns* :test #'eq)))
(defun custom-modifier? (m d)
(and (symbolp d) (pref? (symbol-name d) m)
Expand Down
2 changes: 1 addition & 1 deletion src/init.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:?xpr :?txpr :?mxpr
:?fld :?srch :?grp :?rec))
(defvar *opt* '(optimize (speed 3) (safety 1)))
(defvar *fxns* '(:err :wrn :nope :noop :lst :lit :qt :hld :ghv :pnum :inum :cnt
(defvar *fxns* '(:err :wrn :nope :noop :lit :qt :hld :ghv :pnum :inum :cnt
:fmt :out :jsnstr
:fn :fi :ctx :par :itr :key :val :compct :?? :@get :@*
:read? :some? :all? :none? :smth? :size?
Expand Down

0 comments on commit 247225a

Please sign in to comment.