Sen descrición

813gan 5970a87c6d Add test for c-g hai 1 mes
.github 57ee8c77fc port to gh action cache v4 hai 1 mes
tests 5970a87c6d Add test for c-g hai 1 mes
.clang-format 5d7dea9308 Add clang-format configuration hai 6 meses
.dir-locals.el 5d7dea9308 Add clang-format configuration hai 6 meses
.git-blame-ignore-revs 5d7dea9308 Add clang-format configuration hai 6 meses
.gitignore 6c8cfdb77a Fix calling emacspy from python. rename emacspy-module* to emacspy_module* hai 5 meses
Cask 3958bf7a69 Add Cask hai 5 meses
LICENSE.txt f5a48f6cf2 add LICENSE %!s(int64=3) %!d(string=hai) anos
Makefile 5970a87c6d Add test for c-g hai 1 mes
README.md 2cdb3bf7e2 Update README.md hai 1 ano
console.py 8a9ae9c94d initial commit %!s(int64=5) %!d(string=hai) anos
datatypes.h e8f57ce296 Replace C11 threads with Pthreads hai 1 mes
emacs-module.h 6953e7dd56 Rewrite emacspy_module.pyx in C. Run python in separated thread. hai 1 mes
emacspy.el 3d45e84b17 Fix handling of method name in emacspy-call hai 1 mes
emacspy_threads.py fb49da1020 emacspy_threads: raise instead of deadlocking if ran from main thread %!s(int64=3) %!d(string=hai) anos
requirements.txt 8bddfe7c78 add PyErr_GetRaisedException compatibility macro hai 5 meses
stub.c a1e0d8ebc8 Handle C-g. Disable sub-interpreter support due to python bug hai 1 mes
subinterpreter.c a1e0d8ebc8 Handle C-g. Disable sub-interpreter support due to python bug hai 1 mes
thread_local.c 34dfd5ed85 threading improvements %!s(int64=5) %!d(string=hai) anos

README.md

emacspy

emacspy enables you to program Emacs in Python instead of ELisp. It works by using dynamic modules support introduced in Emacs 25.

Building and loading

Install Cython (pip install cython) and run make. emacspy.so will appear in the current directory. Make sure your Emacs build has loadable modules support enabled (default builds on some distributions don't!):

emacs --help | grep -q module-assertions && echo OK || echo "No loadable modules support"

You can load the module using normal load directive:

(add-to-list 'load-path "~/emacspy")
(load "~/emacspy/emacspy")

The module will expose two ELisp functions eval-python and exec-python.

(eval-python "4+4")

You can use exec-python to load you Python files:

(exec-python "import sys; sys.path.append('/home/user/my-files')")
(exec-python "import mymodule")

Python

Emacspy also exposes Python API for interacting with Emacs. To use it import emacspy module.

import emacspy

# use emacspy.v to access Emacs variables
emacspy.v.tab_width

# use emacspy.f to call Emacs functions
emacspy.f.message("hello")

# returned values are wrapped in EmacsValue
emacspy.f["+"](1, 2) # => <EmacsValue ...>

# use functions to convert to Python values
emacspy.f["+"](1, 2).int()
emacspy.v.page_delimiter.str()