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

Feature: magics always #89

Merged
merged 6 commits into from
Apr 9, 2020
Merged

Feature: magics always #89

merged 6 commits into from
Apr 9, 2020

Conversation

tinmarino
Copy link
Contributor

@tinmarino tinmarino commented Apr 8, 2020

Always prepend and append are implemented. As show and clear to inspect and remove them all. As conversed in issue #85
The first commit contains the real work. The rest is test and doc.

Note on t/20-end-to-end.t

(I renamed it : 10 -> 20 for it to stay the last when adding more test)

The client is not dying sometimes => address already in use (9103 iopub)
For example when my tests did freeze a Ctrl-C killed the kernel but not the client.

pkill raku
P6_JUPYTER_TEST_END_TO_END=1 ra t/20-end-to-end.t

Or more wisely

netstat -laputn | grep 9103   # to find its pid (here 666)
kill -15 666

@bduggan
Copy link
Owner

bduggan commented Apr 9, 2020

Very cool!

However, I think it should execute whatever is in the cell -- so that you can have something like

#% always
say "-----header-----"

This makes it useful in the notebook UI, e.g. to set up a cell that does several things

In this pr --

In [1]: #% always \
      : say "----"
Out[1]:

In [2]: 2
Out[2]: 2

However, it's cool that this works --

In [1]: #% always say 'hi'
Out[1]:

In [2]: 3
hi
Out[2]: 3

I suppose we can keep that even though it could potentially be ambiguous (e.g. if there is a prepend sub defined)

also +1 for nice tests

@tinmarino
Copy link
Contributor Author

Awesome review : nice catch! I made a mistake for believing this was only a check:

my $magic-line = $code.lines[0] or return Nil;
$magic-line ~~ /^ [ '#%' | '%%' ] / or return Nil;

Fixed (c1e019d above):

In [6]: #% always 
      : say "-----header-----"               
Out[6]: 

In [7]: say "May the Magic be always with you"                                             
-----header-----
May the Magic be always with you

@bduggan bduggan merged commit d7caa5a into bduggan:master Apr 9, 2020
@bduggan
Copy link
Owner

bduggan commented Apr 9, 2020

Great!

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

Successfully merging this pull request may close these issues.

None yet

2 participants