diff --git a/README.org b/README.org index 0138b00..d974951 100644 --- a/README.org +++ b/README.org @@ -2124,11 +2124,9 @@ list detailing and motivating each listing: "\\end{document}\n"))) (with-eval-after-load 'ob-lisp - ;; (with-eval-after-load 'slime - ;; (setopt org-babel-lisp-eval-fn #'slime-eval)) - (with-eval-after-load 'sly - (setopt org-babel-lisp-eval-fn #'sly-eval)) - ) + ;; Default to `sly-eval' whenever feasible: + (when (package-installed-p 'sly) + (setopt org-babel-lisp-eval-fn #'sly-eval))) (with-eval-after-load 'emacs (defun set-org-babel-language-activity (lang active) @@ -4005,22 +4003,16 @@ that do not visit a file. :CUSTOM_ID: sec:common-lisp-programming :END: -Listing [[lst:configure-sly]] configures the [[info:sly#Top][Sly (info)]] Common Lisp IDE for Emacs -for use with [[http://www.sbcl.org/][Steel Bank Common Lisp (sbcl)]]: -1. It configures =sly-default-lisp= and =sly-lisp-implementations= as in the - ~sly~ documentation string instead of in the [[info:sly#Multiple Lisps][multiple lisps (info)]] manual. -2. It ensures the [[info:sly#Auto-SLY][automatic connection to the lisp server (info)]] when opening a - Common Lisp file. -3. It configures searching documentation in the [[http://www.lispworks.com/documentation/HyperSpec/Front/][Common Lisp HyperSpec]] according - to the [[info:sly#Basic customization][basic customization (info)]] manual. -Finally, listing [[lst:configure-sly]] uses a technique to [[info:sly#Loading Slynk faster][load Slynk faster (info)]] -by means of a custom core file in src_emacs-lisp{no-littering-var-directory}. -Listing [[lst:sbcl-core-for-sly]] tangles to a script to dump such a [[http://www.sbcl.org/][SBCL]] core. +*** [[https://slime.common-lisp.dev/doc/html/index.html][Slime]] :noexport: +:PROPERTIES: +:CUSTOM_ID: sec:slime +:header-args:emacs-lisp: :exports code :tangle no +:END: #+caption[Configure =slime=]: #+caption: Configure =slime=. #+name: lst:configure-slime -#+begin_src emacs-lisp -n :results silent :tangle no +#+begin_src emacs-lisp -n :results silent (when (ensure-package-installation 'slime) (with-eval-after-load 'slime (setq slime-default-lisp 'sbcl @@ -4048,6 +4040,24 @@ Listing [[lst:sbcl-core-for-sly]] tangles to a script to dump such a [[http://ww (keymap-set slime-prefix-map "M-h" #'slime-documentation-lookup))) #+end_src +*** [[https://joaotavora.github.io/sly/][Sly]] +:PROPERTIES: +:CUSTOM_ID: sec:sly +:END: + +Listing [[lst:configure-sly]] configures the [[info:sly#Top][Sly (info)]] Common Lisp IDE for Emacs +for use with [[http://www.sbcl.org/][Steel Bank Common Lisp (sbcl)]]: +1. It configures =sly-default-lisp= and =sly-lisp-implementations= as in the + ~sly~ documentation string instead of in the [[info:sly#Multiple Lisps][multiple lisps (info)]] manual. +2. It does not ensure the [[info:sly#Auto-SLY][automatic connection to the lisp server (info)]] when + opening a Common Lisp file because it does not play well with =ob-lisp=. +3. It configures searching documentation in the [[http://www.lispworks.com/documentation/HyperSpec/Front/][Common Lisp HyperSpec]] according + to the [[info:sly#Basic customization][basic customization (info)]] manual. +Listing [[lst:slink-sel]] allows to set or get the Sly string elision length. +Finally, listing [[lst:configure-sly]] uses a technique to [[info:sly#Loading Slynk faster][load Slynk faster (info)]] +by means of a custom core file in src_emacs-lisp{no-littering-var-directory}. +Listing [[lst:sbcl-core-for-sly]] tangles to a script to dump such a [[http://www.sbcl.org/][SBCL]] core. + #+caption[Configure =sly=]: #+caption: Configure =sly=. #+name: lst:configure-sly @@ -4086,6 +4096,51 @@ Listing [[lst:sbcl-core-for-sly]] tangles to a script to dump such a [[http://ww (keymap-set sly-prefix-map "M-h" #'sly-documentation-lookup))) #+end_src +#+caption[Get/set Sly ~slynk:*string-elision-length*~ functionality]: +#+caption: Get/set Sly ~slynk:*string-elision-length*~ functionality. +#+name: lst:slink-sel +#+begin_src emacs-lisp -n :results silent +(with-eval-after-load 'sly + (defconst slynk-command-get-sel + "(cdr (assoc 'slynk:*string-elision-length* slynk:*slynk-pprint-bindings*))" + "Slynk \"string elision length\" getter command.") + + (defun slynk-command-set-sel (sel) + "Slynk SEL \"string elision length\" setter command. +SEL values must be positive integers to enable or `nil' to disable elision." + (format "(setf %s %s)" slynk-command-get-sel sel)) + + (defun slynk-get-sel () + "Get the Slynk \"string-elision-length\"." + (cadr (sly-eval `(slynk:eval-and-grab-output ,slynk-command-get-sel)))) + + (defun slynk-set-sel (sel) + "Set the Slynk \"string-elision-length\" SEL. +SEL values must be positive integers to enable or `nil' to disable elision." + (cadr (sly-eval `(slynk:eval-and-grab-output ,(slynk-command-set-sel sel))))) + + (defun slynk-eval-sel-command (string) + "Evaluate the Slynk \"string-elision-length\" command STRING." + (unless (sly-connected-p) + (user-error "Slynk connection is not open: \"M-x sly\"?")) + (message "Slynk string elision length is %S" + (read (cadr (sly-eval `(slynk:eval-and-grab-output ,string)))))) + + (defun slynk-get-string-elision-length () + "Get the Slynk \"string-elision-length\"." + (interactive) + (slynk-eval-sel-command slynk-command-get-sel)) + + (defun slynk-set-string-elision-length (&optional sel) + "Set the Slynk \"string-elision-length\" by evaluting SEL. +Valid SEL values are positive integers to enable or `nil' to disable elision." + (interactive "XSlynk string-elision-length (nil or sel > 0): ") + (unless (or (null sel) (and (integerp sel) (> sel 0))) + (user-error + "Slynk `sel' must evaluate to `nil' or a positive integer (got `%S')" sel)) + (slynk-eval-sel-command (slynk-command-set-sel sel)))) +#+end_src + #+caption[Script to dump a SBCL core for the Sly Common Lisp IDE]: #+caption: Script to dump a SBCL core for the Sly Common Lisp IDE. #+header: :tangle-mode (identity #o755) @@ -4105,9 +4160,152 @@ EOF # End: #+end_src -*** [[https://www.n16f.net/blog/custom-font-lock-configuration-in-emacs/][Common Lisp custom font locking]] +*** [[https://courses.cs.northwestern.edu/325/][CS 325 AI Programming]] :PROPERTIES: -:CUSTOM_ID: sec:cl-custom-font-locking +:CUSTOM_ID: sec:cs-325-ai-programming +:END: + +The [[https://courses.cs.northwestern.edu/325/][CS 325 AI Programming]] course allows to learn Common Lisp by self-study and +the page [[https://courses.cs.northwestern.edu/325/admin/lisp-setup.php][CS 325: Setting up Lisp]] gives instructions how to: +1. [[https://courses.cs.northwestern.edu/325/admin/lisp-setup.php#lisp][Download and install common lisp]]. +2. [[https://courses.cs.northwestern.edu/325/admin/lisp-setup.php#quicklisp][Install Quicklisp]]. +3. [[https://courses.cs.northwestern.edu/325/admin/lisp-setup.php#install-325][Install the CS325 library]]. + +*** [[https://www.quicklisp.org/][Quicklisp]] +:PROPERTIES: +:CUSTOM_ID: sec:quicklisp +:END: + +[[https://www.quicklisp.org/][Quicklisp]] is a library manager for Common Lisp. Listing +[[lst:download+verify-quicklisp]] downloads the [[https://www.quicklisp.org/][Quicklisp]] installation file and +verifies its signature to prevent tampering. Listing [[lst:bootstrap-quicklisp]] +tangles to a shell script allowing to bootstrap [[https://www.quicklisp.org/][Quicklisp]] with [[http://www.sbcl.org/][SBCL]]. Listing +[[lst:quicklisp-sbclrc-file]] tangles to the a [[http://www.sbcl.org/][SBCL]] resource file with [[https://www.quicklisp.org/][Quicklisp]] +support. Listing [[lst:clone-local-projects]] shows how to make local projects out +of unpackaged projects and listing [[lst:register-load-local-projects]] shows how to +register local projects in order to load those unpackaged projects in the same +way as packaged projects. + +#+caption[Download and verify =quicklisp=]: +#+caption: Download and verify =quicklisp=. +#+name: lst:download+verify-quicklisp +#+begin_src shell -n :dir ~ :results none :tangle no +curl -sS -O https://beta.quicklisp.org/quicklisp.lisp +curl -sS -O https://beta.quicklisp.org/quicklisp.lisp.asc +curl -sS -O https://beta.quicklisp.org/release-key.txt +gpg --import release-key.txt +gpg --verify quicklisp.lisp.asc quicklisp.lisp +#+end_src + +#+caption[Bootstrap =quicklisp=]: +#+caption: Bootstrap =quicklisp=. +#+header: :tangle-mode (identity #o755) +#+name: lst:bootstrap-quicklisp +#+begin_src shell -n :noeval :tangle ~/bin/quicklisp-sbcl-bootstrap +#!/bin/sh + +sbcl --load ~/quicklisp.lisp <