-
Notifications
You must be signed in to change notification settings - Fork 7
Should we have a 'silent' cell magic? #16
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
Comments
That's a good idea. This can be done by passing For consistency with Stata, maybe we should name this magic There is one question I have to ask though: why would you not use Stata's native
|
Primarily, because with a native quietly {
dosomething
dosomethingelse
}
I don't know why pystata behaves this way - if you type or paste a multiline The theory behind this magic, on the other hand, is to suppress everything: the command echo and the output. That's also why I suggested a different name than 'quietly'; it's for a different purpose that doesn't really make sense outside the notebook environment. (But I'm not wedded to that.) The less important reason for a magic over a |
That would help for my use case, yes. And, to me, the I think I'd still like to also have a |
Given the interest, I have added the logic necessary to implement such magics over the weekend. There are two new magics and a new configuration option: Magics
Configuration
The logic should be able to handle multi-line comments and change of delimiter correctly. Please check and see if I miss anything. |
I'm not sure I'm going to be able to take the time soon to understand how you're handling the delimiters. (One thing I was worried about with the quietly-noisily approach was handling the |
The way it works right now is, whenever a user requests echo supression,
The processed code is then passed to Following your comment, I have run extensive tests on
|
Just to note that the Stata help file for |
Ok, that makes sense and sounds quite robust. Thank you! What I actually had in mind with my macro-delimit comment, though, was something more along these lines:
But I've never heard of anyone doing that, and I haven't tested it yet. p.s. I see now from the delimit help file that it's not possible to set the delimiter in a previous notebook block and have it carry over to the next block, which was another thing I had been puzzled about. |
Hmm, when defining programs (with update: Actually, program definition doesn't work in that setting (
update2: The same problem occurs for something like a for loop. It complains about the |
With |
Yes, which is why I thought the only acceptable values after |
In Stata the effect of Since
Thanks for the catch. I will post a commit on that soon. |
Program definition and loops should now be properly excluded. The |
As I think about it, a cell feels more akin to running a block of highlighted code. So I'd vote for keeping the default as is (and I never use delimit myself, anyhow). But an option would make sense if there's demand for it. |
The quietly magic is working for me, but I'm running into various other issues as I test out the noecho mode. For example, the commands within a loop would be echoed. I started #18 to address that and a few other niggles. |
I'm also hitting a corner-case delimit error when
triggers:
I haven't been able to find a fix so far, myself. |
Hmmm, resetting delimit to |
To follow up, I've now made |
I was thinking about #4 again in light of PR #15 and trying to work out when the echo-all behaviour is most annoying. For me, it's usually when I want to avoid the screen filling up with a bunch of echoed commands that have little or no output. For example, if I'm putting together an
etable
it looks something like this:Or in a setup block—since pystata doesn't pick up
profile.do
, every notebook I make starts with:version 17 set varabbrev off global data_root… …
and other throat-clearing.
So I was wondering: what if we just added a cell magic, e.g.
*%silent
, that tells the kernel not to print the output of that particular cell unless an exception is thrown? I'm happy to take a crack at implementing this but I thought I'd put it up for discussion first.@hugetim, would this be any good for your use case?
The text was updated successfully, but these errors were encountered: