From 82ca7b7ed83d1831fcc37dd6fd87f217901bd878 Mon Sep 17 00:00:00 2001 From: vindarel Date: Fri, 7 Jan 2022 17:41:20 +0100 Subject: [PATCH] Developer utilities: add Quicksearch --- ciel.asd | 2 ++ docs/libraries.md | 28 ++++++++++++++++++++++++++++ repl.lisp | 6 +++--- shell-utils.lisp | 7 +++++-- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ciel.asd b/ciel.asd index 84a1b55..2f85718 100644 --- a/ciel.asd +++ b/ciel.asd @@ -105,9 +105,11 @@ ;;; ;;; User helpers. + ;;; ;TODO: we don't want these dependencies when we build a binary. ;;; :named-readtables :clesh ;; shell pass-through + :quicksearch ;; search on GitHub, Cliki, Quickdocs. ) :components ((:module "src" :components diff --git a/docs/libraries.md b/docs/libraries.md index 1acf72f..82742b2 100644 --- a/docs/libraries.md +++ b/docs/libraries.md @@ -625,3 +625,31 @@ Learn more with: (arglist #'foo) ;; (a b c &optional d) ``` + +### Searching for libraries on GitHub, Quickdocs and Cliki (quicksearch) + +We include +[Quicksearch](https://github.com/lisp-maintainers/quicksearch), a +simple search utility for Common Lisp libraries: + + (qs:? "ciel" :u) + +this will search on GitHub, Quickdocs and Cliki for "ciel", and it +will print the URL of search results. + +``` +SEARCH-RESULTS: "ciel" +====================== + + Cliki + ----- + cl-cron + http://www.cliki.net/cl-cron + + GitHub + ------ + CIEL + https://github.com/ciel-lang/CIEL + cl-cron + https://github.com/lisp-mirror/cl-cron +``` diff --git a/repl.lisp b/repl.lisp index b59aad6..4fdafee 100755 --- a/repl.lisp +++ b/repl.lisp @@ -243,11 +243,11 @@ (t (apply fun (subseq args 0 l)))))) (defun handle-special-input (text) - (let* ((splt (str:words text)) - (k (subseq (car splt) 1 (length (car splt)))) + (let* ((words (str:words text)) + (k (subseq (car words) 1 (length (car words)))) (v (gethash k *special*))) (if v - (call-special v (car splt) (cdr splt)) + (call-special v (car words) (cdr words)) (format *error-output* "Unknown special command: ~a~%" k)))) (defun evaluate-lisp (text parsed) diff --git a/shell-utils.lisp b/shell-utils.lisp index 314f34d..e0dc502 100644 --- a/shell-utils.lisp +++ b/shell-utils.lisp @@ -55,10 +55,13 @@ else if (functionp program) return program)) (defun basename (arg) - (when arg - (namestring (pathname-name arg)))) + ;; ARG can be any string. This fails with "(qs:?" (note the "?"). + (ignore-errors + (when arg + (namestring (pathname-name arg))))) (defun shell-command-wrapper-p (command) + "Is this command (string) a shell wrapper?" (find (basename command) *command-wrappers* :test #'string-equal))