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

Syntax highlighting in packages #3330

Open
mahrud opened this issue Jun 25, 2024 · 5 comments
Open

Syntax highlighting in packages #3330

mahrud opened this issue Jun 25, 2024 · 5 comments

Comments

@mahrud
Copy link
Member

mahrud commented Jun 25, 2024

A pretty glaring caveat of syntax highlighting is that it doesn't work for packages. Here's an example with only symbols from Core being highligted, which looks really odd.

A pretty simple solution would be to generate a prism grammar for each package in installPackage and load it in the header of html files from that package.

It would be great if the same worked for emacs.

@mahrud
Copy link
Member Author

mahrud commented Jun 25, 2024

There are also a few related suggestions in .#3298.

@pzinn
Copy link
Contributor

pzinn commented Jul 3, 2024

(copied from zulip) a tangentially related issue. Say one defines a new function myfunc, then neither in emacs nor in the webapp will the autocompletion work if one types say myf followed by tab. However it does work in the terminal using readline. Why can't we have something similar without readline? it can't be that hard...

@pzinn
Copy link
Contributor

pzinn commented Jul 3, 2024

@d-torrance's answer:

I've played around with this a bit. We could potentially do something like call apropos to get a list of possible autocompletions, but output it in such a way that the editor doesn't display the output to the user. This is basically how autocompletion works in the Python Emacs mode

originally I was hoping we could reuse the code made for readline but I guess most of the work is done by readline itself...

@pzinn
Copy link
Contributor

pzinn commented Jul 3, 2024

continuing my digression, I'm assuming this is the relevant part of expr.d:

export completions(s:string):array(string) := (
     n := length(s);
     if n == 0 then return array(string)();		    -- don't complete the null string
     v := newvarstringarray(6);
     d := globalDictionary;
     while (
	  lockRead(d.symboltable.mutex);
	  foreach bucket in d.symboltable.buckets do (
	       b := bucket;
	       while true do when b
	       is null do break
	       is q:SymbolListCell do (
		    t := q.word.name;
		    if isalnum(t.0) && n <= length(t) && 0 == strncmp(s,t,n) then append(v,t);
		    b = q.next; ));
	  unlock(d.symboltable.mutex);
	  d != d.outerDictionary) do d = d.outerDictionary;
     extract(v));

@mahrud
Copy link
Member Author

mahrud commented Jul 4, 2024

It is not a digression. Syntax highlighting and autocompletion have the same purpose.

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

No branches or pull requests

2 participants