Function: org-persist--read-elisp-file

org-persist--read-elisp-file is a byte-compiled function defined in org-persist.el.gz.

Signature

(org-persist--read-elisp-file &optional BUFFER-OR-FILE)

Documentation

Read elisp data from BUFFER-OR-FILE or current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-persist.el.gz
(defun org-persist--read-elisp-file (&optional buffer-or-file)
  "Read elisp data from BUFFER-OR-FILE or current buffer."
  (unless buffer-or-file (setq buffer-or-file (current-buffer)))
  (with-temp-buffer
    (if (bufferp buffer-or-file)
        (set-buffer buffer-or-file)
      (insert-file-contents buffer-or-file))
    (condition-case err
        (let ((coding-system-for-read 'utf-8)
              (read-circle t)
              (start-time (float-time)))
          ;; FIXME: Reading sometimes fails to read circular objects.
          ;; I suspect that it happens when we have object reference
          ;; #N# read before object definition #N=.  If it is really
          ;; so, it should be Emacs bug - either in `read' or in
          ;; `prin1'.  Meanwhile, just fail silently when `read'
          ;; fails to parse the saved cache object.
          (prog1
              (read (current-buffer))
            (org-persist--display-time
             (- (float-time) start-time)
             "Reading from %S" buffer-or-file)))
      ;; Recover gracefully if index file is corrupted.
      (error
       ;; Remove problematic file.
       (unless (bufferp buffer-or-file) (delete-file buffer-or-file))
       ;; Do not report the known error to user.
       (if (string-match-p "Invalid read syntax" (error-message-string err))
           (message "Emacs reader failed to read data in %S. The error was: %S"
                    buffer-or-file (error-message-string err))
         (warn "Emacs reader failed to read data in %S. The error was: %S"
               buffer-or-file (error-message-string err)))
       nil))))