Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[RFC] zsh/zpython module



Wondering if I write zsh/zpython module will it be included?

This is the module that embeds python interpreter into zsh. Proposed features:

Minimal:
- zpython command similar to :python in vim.
- zsh python module capable of setting the environment variables.
Intended:
- zpython command
- zsh python module capable of
  - getting and setting local, global and exported variables, including special ones
  - defining zsh commands
  - defining “magic variables” (those that are running python code when their value is requested)
  - defining zle widgets

Reasoning:
1. there are some jobs that when implemented using shell scripting or external commands are very time-consuming. I know two examples of this: zsh-syntax-highlighting and new powerline prompt (it has very noticeable delay in its current status, but even just `PS1='$(python -c "print 2")'` has noticeable delay).
2. I know no other good ways of doing this: if I put powerline into background all IPC I can imagine is a crap:
  - pipes are not available;
  - zsh/zpty is an overkill;
  - coproc can run only one process in background;
  - UNIX sockets/FIFO files require some place you can write to on filesystem, require some effort to generate unique names, require garbage-collecting when shell quits or stops using prompt, require collecting stale files after a crash.
3. Any method is going to lose performance for IPC: fist you need to tell that new prompt is needed and update changed environment variables (like `$?`), then wait until kernel wakes the background process up and it will generate the prompt, then wait until kernel wakes your process up to get and display new value. Zsh/zpython is running python in the same process, no need in IPC. And Vim has already shown that powerline performs pretty well in this case.

I will welcome any comments about where I should look first when writing this module, what else I could include and what I could not because it is not easily doable.


------------
http://titov.by - Путь выхода из кризиса!



Messages sorted by: Reverse Date, Date, Thread, Author