Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mschuldt/pyel
A Python to Emacs-Lisp Compiler
https://github.com/mschuldt/pyel
Last synced: 1 day ago
JSON representation
A Python to Emacs-Lisp Compiler
- Host: GitHub
- URL: https://github.com/mschuldt/pyel
- Owner: mschuldt
- License: gpl-3.0
- Created: 2013-10-16T21:15:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-02-27T00:21:00.000Z (almost 8 years ago)
- Last Synced: 2025-01-09T22:37:13.200Z (9 days ago)
- Language: Emacs Lisp
- Homepage:
- Size: 1.61 MB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
Pyel translates PYthon to Emacs Lisp.
Pyel can translate a large subset of Python, it takes advantage of
reconstructable types and type annotations to generate efficient code.
Pyel support Python syntactic extensions that allow for calling e-lisp macros
and making additional type annotation.* setup
In your configuration file:
#+Begin_SRC emacs-lisp
(setq pyel-directory "path/to/pyel/directory")
(require 'pyel)
#+END_SRC
* usage
#+Begin_SRC emacs-lisp
(pyel "python code string")
#+END_SRC
Returns unevaled e-lisp with supporting function added to `pyel-function-definitions'
#+Begin_SRC emacs-lisp
(pyel-load "filename.py")
#+END_SRC
Convert python file to an e-lisp file, bypte compile it and load it.
** interactive usage
#+Begin_SRC emacs-lisp
M-x ipyel
#+END_SRC
An ielm style repl
#+Begin_SRC emacs-lisp
M-x pyel-mode
#+END_SRC
Displays the translated python side-by-side in a split buffer
(still buggy, best to avoid for now)* example
#+Begin_SRC python
@interactive
def show_ascii_table ():
'''Display basic ASCII table (0 thru 128).'''
switch_to_buffer('*ASCII*')
local_set_key('q', `bury_buffer)
erase_buffer()
save_excursion(
i = -1
insert('ASCII characters 0 thru 127.\n\n')
insert(' Hex Dec Char| Hex Dec Char| Hex Dec Char| Hex Dec Char\n')
while i < 31:
for k in range(4):
i += (32 if k else 1)
insert(format('%4x %4d %4s %s', i, i, single_key_description(i), '\n' if k == 3 else '| '))
i = i - 96
)
#+END_SRC
#+Begin_SRC emacs-lisp :tangle mbs-lisp/dotemacs.el
(def show-ascii-table nil
(interactive)
"Display basic ASCII table (0 thru 128)."
(let (i)
(switch-to-buffer "*ASCII*")
(local-set-key "q" 'bury-buffer)
(erase-buffer)
(save-excursion (setq i (- 1))
(insert "ASCII characters 0 thru 127.\n")
(insert " Hex Dec Char| Hex Dec Char| Hex Dec Char| Hex Dec Char\n")
(while (< i 31)
(py-for k in (py-range 4)
(setq i (+ i (if (py-bool k) 32 1)))
(insert (format "%4x %4d %4s %s"
i i
(single-key-description i)
(if (py-bool (pyel-==5 k 3))
"\n" "| "))))
(setq i (- i 96))))))
#+END_SRC