Closed kylebarron closed 5 years ago
@mcaceresb I still want to implement something like this, although definitely behind a feature flag that is off by default. Since Atom/Hydrogen is selection based, there are tons of times I want to just run the local by itself to see its value, and hate having to type di "`macro'"
, like
power_param, `options' v2 _value outcome(`out') suffix(`suffix') `controls' if(if `base' & `sample1')
Ideally I'd love to be able to select just `out'
and press ctrl-enter
to see its value. I think this would be straightforward with the restriction that in this mode you couldn't store a program name in a macro and send just the macro to run it. -- If the first character sent to the kernel is `
and this mode is active, run di "`macro'"
to Stata.
While I do think the idea sounds quite useful, I don't like the way you have suggested for how to implement this, though I have a hard time explaining why.
Can I suggest this be an ofshoot of the code introspection code? If the word starts with `
or $
then show the local/global.
As a code introspection implementation this can be more general, since Atom can request it for any word. First look for global/local if the word starts like that. Otherwise look for help, and if no help is found start looking for any programs, variables, locals, matrices, etc. matching. Then list
out can refer to
local [value]
str32 variable [first value]
program [where found; e.g. directory, built-in, user-defined]
etc
Something like that. Obviously presented in a nice table or list, the above is just the contents idea. You know what I mean?
Well in Atom, code introspection comes up in a separate pane, and takes up part of the screen. It would be more visually convenient and appealing if just the value were displayed next to the code.
Ah! Ok, this makes more sense now. I kind of assumed you could customize the introspection to be a tooltip, which is the default in qtconsole.
Random suggestion: Wouldn't it be easier to make a...macro/function/shortcut (not sure what the term is in atom) that grabs a word chunk and if it is a local then send disp `"`local'"'
or is that actually more cumbersome?
I think we can add an option like
%set keyword {eval|inspect}
If a single word is sent to the kernel, evaluate it or give feedback (inspect
) on what object that word might refer to. It would be easy to run programs, etc. by just prepending noi
if this is set to inspect
and most commands wouldn't trigger it (since most commands are not a single word).
I kind of assumed you could customize the introspection to be a tooltip, which is the default in qtconsole. This is separate I think. I haven't tried introspection in qtconsole yet.
Random suggestion: Wouldn't it be easier to make a...macro/function/shortcut (not sure what the term is in atom) that grabs a word chunk and if it is a local then send disp
"
local'"' or is that actually more cumbersome?
No that would actually be really annoying because it would have to alter the text in the editor under the selection, run Hydrogen, then alter the text back.
I think we can add an option
Yes but I think it's still best to only inspect objects that we know are objects. And then try running it in Stata if it doesn't exist.
Closing as too difficult for what it's worth
If I have a local in my environment named
x
and set to5
, and I sendto Stata,
which program
then by matching againstprogram dir
.di `local'
. Might also do this for r-class or e-class?Note: Add
check_env
flag torun
function so that I only check environment when needed.Make sure this is an option in the configuration file