mishoo / elisp-reader.el Goto Github PK
View Code? Open in Web Editor NEWCustomizable reader for Emacs Lisp
Customizable reader for Emacs Lisp
Rather than simply a progn
at the end of elisp-reader, how about making it possible to enable/disable, then it could maybe be scoped for reading certain things.
(defvar er--original-read (symbol-function 'read))
(defvar er--original-read-from-string (symbol-function 'read-from-string))
(defvar er--original-load-read-function load-read-function)
(defun er-enable ()
(interactive)
(setq er--original-read (symbol-function 'read)
er--original-read-from-string (symbol-function 'read-from-string)
er--original-load-read-function load-read-function)
(fset 'read (symbol-function 'er-read))
(fset 'read-from-string (symbol-function 'er-read-from-string))
(setq load-read-function (symbol-function 'er-read)))
(defun er-disable ()
(interactive)
(fset 'read er-original-read)
(fset 'read-from-string er--original-read-from-string)
(setq load-read-function er--original-load-read-function))
(defcustom er-enabled nil
"Whether to use the extensible elisp-reader when reading elisp."
:set
(lambda (option new-value)
(if new-value (er-enable) (er-disable))))
E.g., something like
(defconst er-standard-sharpsign-dispatcher-alist
(concat (er-enumerate-sharpsign-digit-dispatchers)
(er-enumerate-original-sharpsign-dispatchers)
'((?\' . (lambda (in x) (list 'function (er-read-datum in)))))))
(defcustom er-sharpsign-dispatcher-alist er-standard-sharpsign-dispatcher-alist
"An alist mapping characters following ?# to reader functions.")
;; This regexp reader can now be conditionally enabled
(add-to-list er-sharpsign-dispatcher-alist
'(?\/ . (lambda (in x) (er-read-regexp in))))
Or, to prevent users from breaking the elisp reader completely, the alist could start empty and only be used before er-croak
in the catchall of your existing dispatcher.
local
, as a bare name should certainly be in its own module. The regex reader not necessarily, so long as it isn’t added to the sharpsign reader by default (see #2), but I personally like the idea of elisp-reader.el
having simply the extensible standard reader, and then extensions separate.
I have a complete Emacs Lisp implementation of the Common Lisp reader here:
https://github.com/larsbrinkhoff/emacs-cl/blob/master/cl-reader.el
Even though this is still in “alpha”, I think it’s a useful library. It’d be great to see it published.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.