Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: example .sbclrc file #9

Open
vindarel opened this issue Apr 13, 2024 · 5 comments
Open

Added: example .sbclrc file #9

vindarel opened this issue Apr 13, 2024 · 5 comments

Comments

@vindarel
Copy link
Owner

Here is an example ~/.sbclrc file that you can use.

https://github.com/vindarel/common-lisp-course-in-videos/blob/master/.sbclrc

You don't strictly speaking need one to use SBCL, you can start without it.

It includes the snippet that we saw to disable the interactive debugger, which can be useful when trying things out in the terminal.

@stephensmith9
Copy link

stephensmith9 commented Nov 21, 2024

The format statement on line 79 of the example .sbclrc produces this error:

(SB-FORMAT::FORMAT-ERROR-AT* "*** reminder: we now disable the interactive debugger. Remove this setting from ~/.sbclrc when using Slime or another IDE. *****" 81 "No matching closing slash" NIL)

I simply removed the ~/ and it goes away. I believe the ~/ is a format directive? How can we escape a forward slash in a format string? I tried googling, and surprisingly found nothing to help me. Using a preceding \ doesn't seem to work as I would have expected?

Not a big deal, but I'm really curious if format can handle printing a literal ~/ in its output?

@vindarel
Copy link
Owner Author

vindarel commented Nov 21, 2024

aaargh the fail. Thanks for the report.

Only ~ introduces a format directive. ~/ introduces a custom name for a format directive, it should be between / /. Example: https://github.com/vindarel/format-colors (I first read this on Edi Weitz' CL Recipes)

Yes, with ~~.

https://lispcookbook.github.io/cl-cookbook/strings.html#structure-of-format

Print a tilde with ~~, or 10 with ~10~.

@stephensmith9
Copy link

stephensmith9 commented Nov 21, 2024

Thanks Vincent!

I changed the code to this (but I like your solution better):

(uiop:format! t "*** REMINDER ***: we now disable the interactive debugger. Remove this setting from ")
(let ((pathname (uiop:parse-unix-namestring "~\/.sbclrc")))
     (princ pathname))			    
(uiop:format! t " when using Slime or another IDE.~%")
(setf *debugger-hook* #'print-condition-hook)

So for completeness, what you are suggesting would look like this:

(uiop:format! t "*** REMINDER ***: we now disable the interactive debugger. Remove this setting from ~~/.sbclrc when using Slime or another IDE.~%")

@stephensmith9
Copy link

Another suggestion, while we're on the topic of the .sbclrc file, I changed the hard-coded reference to the user folder in the quicklisp section to use (user-homedir-pathname) instead, as per this cl-cookbook page:

#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

but not sure how portable this is? Works on my MacOS setup. Haven't tested on Windows.

@vindarel
Copy link
Owner Author

spot-on again. I wonder why Quicklisp hardcodes the user name.

It should be portable on implementations (it's in a SBCL file anyways), and it's better than "/home/user/" for Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants