Function: edebug-read-special

edebug-read-special is a byte-compiled function defined in edebug.el.gz.

Signature

(edebug-read-special STREAM)

Documentation

Read from STREAM a Lisp object beginning with #.

Turn #'thing into (function thing) and handle the read syntax for circular objects. Let read read everything else.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/edebug.el.gz
(defun edebug-read-special (stream)
  "Read from STREAM a Lisp object beginning with #.
Turn #\\='thing into (function thing) and handle the read syntax for
circular objects.  Let `read' read everything else."
  (catch 'return
    (forward-char 1)
    (let ((start (point)))
      (cond
       ((eq ?\' (following-char))
        (forward-char 1)
        (throw 'return
               (list
                (edebug-storing-offsets (- (point) 2) 'function)
                (edebug-read-storing-offsets stream))))
       ((and (>= (following-char) ?0) (<= (following-char) ?9))
        (while (and (>= (following-char) ?0) (<= (following-char) ?9))
          (forward-char 1))
        (let ((n (string-to-number (buffer-substring start (point)))))
          (when read-circle
            (cond
             ((eq ?= (following-char))
              ;; Make a placeholder for #n# to use temporarily.
              (let* ((placeholder (cons nil nil))
                     (elem (cons n placeholder)))
                (push elem edebug-read-objects)
                ;; Read the object and then replace the placeholder
                ;; with the object itself, wherever it occurs.
                (forward-char 1)
                (let ((obj (edebug-read-storing-offsets stream)))
                  (lread--substitute-object-in-subtree obj placeholder t)
                  (throw 'return (setf (cdr elem) obj)))))
             ((eq ?# (following-char))
              ;; #n# returns a previously read object.
              (let ((elem (assoc n edebug-read-objects)))
                (when (consp elem)
                  (forward-char 1)
                  (throw 'return (cdr elem))))))))))
      ;; Let read handle errors, radix notation, and anything else.
      (goto-char (1- start))
      (read stream))))