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

Notionflux rewrite: support REPL, line-editing, etc #118

Merged
merged 15 commits into from
Jun 21, 2019

Conversation

wilhelmy
Copy link
Collaborator

As mentioned on IRC I've rewritten notionflux.

Notable features:

  • Dual-licensed as LGPL/GPL to conform with notion's license as well as GNU readline's, a bit of a hack. (LGPL wouldn't be required but this should allow for shipping the source package entirely under an LGPL label...? I'm not a lawyer and I can change it to plain GPL if that simplifies things)
  • readline for line-editing
  • REPL mode, uses mod_notionflux and mod_query on the notion side to tab-complete lua expressions
  • linked against lua now to check whether a statement is complete before it is sent

Please test and enjoy!

@raboof
Copy link
Owner

raboof commented Jun 20, 2019

Dual-licensed as LGPL/GPL

I think this makes sense: this means if we ever find a LGPL-compatible alternative to libreadline we can switch to that. Indeed binaries of the notionflux utility must be GPL, but that seems fine.

Travis suggests the Makefile still needs some tweaking though?

@raboof
Copy link
Owner

raboof commented Jun 20, 2019

I guess perhaps on travis libreadline is not installed?

@wilhelmy
Copy link
Collaborator Author

wilhelmy commented Jun 20, 2019

Dual-licensed as LGPL/GPL

I think this makes sense: this means if we ever find a LGPL-compatible alternative to libreadline we can switch to that. Indeed binaries of the notionflux utility must be GPL, but that seems fine.

The most popular libreadline replacement under a permissive license with compatible API is BSD libedit (used by many tools like e.g. llvm's lldb), however it isn't as fully-featured as GNU readline and it involves doing more work by hand. This effort started out by extending notionflux with libedit, but in the end I figured it's less effort to rewrite notionflux entirely than to use it. YMMV.

Travis suggests the Makefile still needs some tweaking though?

Seems you're right, I'll add libreadline-dev to .travis.yml

@wilhelmy
Copy link
Collaborator Author

Apparently debian does not install the readline.pc file used by pkg-config :(
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901650

Copy link
Owner

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick look at the code looks great, will test in more detail later!

{
perror(s);
exit(1);
Display *dpy = XOpenDisplay(NULL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks tab-indented, while the general coding style is 4 spaces. I guess we should introduce an autoformatter...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't follow the guidelines very much, especially since the general coding style has weird rules about whitespace IMO (no spaces around most operators) that I've never seen anyone else use - feel free to fix it up as you deem fit. I had an awful mix of tabs and spaces at some point, so I just settled for tabs since I figured it's semi-independent anyway and that's what my editor was configured to use (changing those settings is like deliberately hammering things under my fingernails).

Thanks for the feedback :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, yeah it's a bit inconventional, and I think not applied consistently across the codebase as it is either. Added #125.

Remember kids, don't stay up late and write memory allocation code
Copy link
Owner

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

{
perror(s);
exit(1);
Display *dpy = XOpenDisplay(NULL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, yeah it's a bit inconventional, and I think not applied consistently across the codebase as it is either. Added #125.

@raboof raboof merged commit 347226e into raboof:master Jun 21, 2019
@raboof raboof changed the title rewrite of notionflux with REPL, line-editing and so forth Notionflux rewrite: support REPL, line-editing, etc Jun 21, 2019
@raboof raboof added the notionflux run-time Lua interface label Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notionflux run-time Lua interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants