GitHub - pythonic-emacs/pythonic: Utility functions for writing pythonic emacs p...
source link: https://github.com/pythonic-emacs/pythonic
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pythonic
Utility functions for writing pythonic emacs package.
Installation
You can install this package form Melpa
M-x package-install RET pythonic RET
Usage
This library provide function for convenient running python on
different platforms on local and remote hosts including Docker
containers and Vagrant virtual machines. To use pythonic
with
Docker you need to install
docker-tramp Emacs
package.
You can use remote interpreter from the tramp buffer.
(cd "/ssh:user@host:/home/user/") ;; or (cd "/docker:root@container:/root/")
Functions
pythonic-call-process
Pythonic wrapper around call-process
.
FILE is the input file. BUFFER is the output destination. DISPLAY
specifies to redisplay BUFFER on new output. ARGS is the list of
arguments passed to call-process
. CWD will be working directory for
running process.
(pythonic-call-process :buffer "*Pythonic*" :args '("-V") :cwd "~")
pythonic-start-process
Pythonic wrapper around start-process
.
PROCESS is a name of the created process. BUFFER is a output
destination. ARGS are the list of args passed to start-process
. CWD
will be working directory for running process. FILTER must be a
symbol of process filter function if necessary. SENTINEL must be a
symbol of process sentinel function if necessary. QUERY-ON-EXIT will
be corresponding process flag.
(pythonic-start-process :process "pythonic" :buffer "*Pythonic*" :args '("-c" "print('PING')") :cwd "~" :filter (lambda (process output) (message output)) :sentinel (lambda (process event) (message "Done.")) :query-on-exit nil)
pythonic-remote-p
Determine remote or local virtual environment.
(pythonic-remote-p)
pythonic-remote-docker-p
Determine docker remote virtual environment.
(pythonic-remote-docker-p)
pythonic-remote-vagrant-p
Determine vagrant remote virtual environment.
(pythonic-remote-vagrant-p)
pythonic-remote-user
Get user of the connection to the remote python interpreter.
(pythonic-remote-user)
pythonic-remote-host
Get host of the connection to the remote python interpreter.
(pythonic-remote-host)
pythonic-remote-port
Get port of the connection to the remote python interpreter.
(pythonic-remote-port)
Commands
pythonic-activate
Activate python virtual environment. Tramp paths are supported.
pythonic-deactivate
Deactivate python virtual environment.
Project settings
You can change the default docker-compose file name and set a default service name to run the pythonic commands.
Add these lines to the .dir-locals.el
file in the project root
directory.
((python . ((pythonic-docker-compose-filename . "local.yml") (pythonic-docker-compose-service-name . "web"))))
You can change the interpreter that pythonic uses. This is especially useful when you have set your python-shell-interpreter
to something like jupyter-console
. By default, it'll use python-shell-interpreter
.
To change it:
(setq pythonic-interpreter "python")
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK