Skip to content

Make use of the reader customizable #4

@sellout

Description

@sellout

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))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions