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

SLIME fails when highlighting compilation notes from slime-load-system #14

Open
kchanqvq opened this issue Feb 7, 2023 · 2 comments
Open

Comments

@kchanqvq
Copy link

kchanqvq commented Feb 7, 2023

The culprit seems to be that swank/source-path-parser:source-path-file-position and swank/source-path-parser:source-path-string-position etc call guess-reader-state, which will return a standard read table for literate-lisp's org file streams. Testing for file type doesn't always work because sometime we just have a string input stream rather than file stream.

My current workaround is to add this in my .asd file

#+(and sbcl swank)
(in-package #:swank/source-path-parser)
#+(and sbcl swank)
(when (sb-int:encapsulated-p 'guess-reader-state :literate-lisp)
  (sb-int:unencapsulate 'guess-reader-state :literate-lisp))
#+(and sbcl swank)
(sb-int:encapsulate 'guess-reader-state :literate-lisp
                    (lambda (orig-func stream)
                      (multiple-value-bind (readtable package)
                          (funcall orig-func stream)
                        (let ((point (file-position stream)))
                          (file-position stream 0)
                          (let ((line (read-line stream nil nil)))
                            (file-position stream point)
                            (when (and line (starts-with-p line "# "))
                              (setq readtable (copy-readtable readtable))
                              (let ((*readtable* readtable))
                                (literate-lisp:install-globally))))
                          (values readtable package)))))

I think this could be made portable. sb-int:encapsulate is non-portable but it's just for advicing guess-reader-state. What do you think?

@jingtaozf
Copy link
Owner

@kchanqvq I didn't meet this issue before, can you show me how to reproduce it? Thanks.

I think we can add advice to guess-reader-state if we can't update readtable in a Emacs buffer like this: https://github.com/joaotavora/sly-named-readtables

@kchanqvq
Copy link
Author

kchanqvq commented Sep 5, 2023

Sure, just to make sure we are on the same page, are you using SLIME? I encounter this issue when I M-x slime-load-system some-project that trigger some compilation note. A minimal example:

some-project.asd

(asdf:defsystem some-project
  :defsystem-depends-on ("literate-lisp")
  :components ((:org "some-project")))

some-project.org

# -*- Mode: POLY-ORG ;-*- ---
#+begin_src lisp
(defun x ())
(defun x ())
#+end_src

This generates a illegal sharp macro character: #\ error when M-x slime-load-system. If the second defun is removed then the error does not occur (because it now does not generate compiler notes).

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