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

OUT buffer purpose? #16

Closed
bjornbm opened this issue May 7, 2023 · 2 comments
Closed

OUT buffer purpose? #16

bjornbm opened this issue May 7, 2023 · 2 comments

Comments

@bjornbm
Copy link
Contributor

bjornbm commented May 7, 2023

Better as a separate issue (from #12):

What is the idea/philosophy and intended use for the OUT buffer? Is it meant to be used as a scratchpad by the user? Or for uses such as you implemented here, for ple to communicate with the user? Or both?

Their is no mention of OUT in the README. Also, ^O is not documented in the help screen.

Thanks

@philanc
Copy link
Owner

philanc commented May 7, 2023

The idea is to have one temp buffer that can switched to very quickly/easily. So with just one keystroke.

I kept ^O, not used otherwise, for this usage. ^O switches back and forth between the current buffer and the OUT buffer.

OUT can be used as a scratchpad, as a sort of extended clipboard, and also to receive the output of programs launched by the editor from the current buffer.

As an example, I have added to the default ple_init.lua what I think is a better eval_lua_buffer command. Maybe more idiosyncratic, but IMHO more useful.

The former version took the content of current buffer and loaded it and run it within the editor Lua environment. It could be useful, but obsiously dangerous for arbitrary Lua code. In addition it does not capture the code standard output (print output)

The new version launches a new Lua interpreter with the buffer content as its standard input. The output is captured (with os.popen()). Now, the question is where to display this output?

The first approach was to insert the output at the end of the current buffer, after the program. But then if I want to run again the program, I must either cut the output first and move it elsewhere, which is clumsy, or wrap the output into a Lua multi-line comment.

The more the program is run, the more output accumulates at the end in comments. Moving back and forth between the program and the output gets quickly old.

A better solution would be to append the output to another buffer and and switch back and forth, keeping the context (the cursor) independently in each buffer.

As ple doesn't support multiple windows (and probably won't), I believe the best option is to dedicate a buffer for other programs output and provide the simplest / fastest way to switch back and forth, thus with a single keystroke (^O).

I don't know if all this rambling makes sense to you. You may try the e.eval_lua_buffer() function (bound to ^X-l) in the last ple_init, and play with ^O.

I have left commented out the code inserting the Lua output as a comment at the end of the current buffer, if you are curious to compare :-)

@bjornbm
Copy link
Contributor Author

bjornbm commented May 8, 2023

Thanks for elaborating! 👍 I proposed a few lines for the README in #17.

@bjornbm bjornbm closed this as completed May 8, 2023
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

No branches or pull requests

2 participants