elisp-reader.el icon indicating copy to clipboard operation
elisp-reader.el copied to clipboard

Make `#` reader customizable

Open sellout opened this issue 2 years ago • 0 comments

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.

sellout avatar May 18 '23 15:05 sellout