- (let ((rout (read-from-string ielm-string)))
- (setq ielm-form (car rout)
- ielm-pos (cdr rout)))
- (error (setq ielm-result (error-message-string err))
- (setq ielm-error-type "Read error")))
- (unless ielm-error-type
- ;; Make sure working buffer has not been killed
- (if (not (buffer-name ielm-working-buffer))
- (setq ielm-result "Working buffer has been killed"
- ielm-error-type "IELM Error"
- ielm-wbuf (current-buffer))
- (if (ielm-is-whitespace-or-comment (substring ielm-string ielm-pos))
- ;; To correctly handle the ielm-local variables *,
- ;; ** and ***, we need a temporary buffer to be
- ;; current at entry to the inner of the next two let
- ;; forms. We need another temporary buffer to exit
- ;; that same let. To avoid problems, neither of
- ;; these buffers should be alive during the
- ;; evaluation of ielm-form.
- (let ((*1 *)
- (*2 **)
- (*3 ***)
- ielm-temp-buffer)
- (set-match-data ielm-match-data)
- (save-excursion
- (with-temp-buffer
- (condition-case err
- (unwind-protect
- ;; The next let form creates default
- ;; bindings for *, ** and ***. But
- ;; these default bindings are
- ;; identical to the ielm-local
- ;; bindings. Hence, during the
- ;; evaluation of ielm-form, the
- ;; ielm-local values are going to be
- ;; used in all buffers except for
- ;; other ielm buffers, which override
- ;; them. Normally, the variables *1,
- ;; *2 and *3 also have default
- ;; bindings, which are not overridden.
- (let ((* *1)
- (** *2)
- (*** *3))
- (kill-buffer (current-buffer))
- (set-buffer ielm-wbuf)
- (setq ielm-result
- (eval ielm-form lexical-binding))
- (setq ielm-wbuf (current-buffer))
- (setq
- ielm-temp-buffer
- (generate-new-buffer " *ielm-temp*"))
- (set-buffer ielm-temp-buffer))
- (when ielm-temp-buffer
- (kill-buffer ielm-temp-buffer)))
- (error (setq ielm-result (error-message-string err))
- (setq ielm-error-type "Eval error"))
- (quit (setq ielm-result "Quit during evaluation")
- (setq ielm-error-type "Eval error")))))
- (setq ielm-match-data (match-data)))
- (setq ielm-error-type "IELM error")
- (setq ielm-result "More than one sexp in input"))))
+ (let ((rout (read-from-string string)))
+ (setq form (car rout)
+ pos (cdr rout)))
+ (error (setq result (error-message-string err))
+ (setq error-type "Read error")))
+ (unless error-type
+ ;; Make sure working buffer has not been killed
+ (if (not (buffer-name ielm-working-buffer))
+ (setq result "Working buffer has been killed"
+ error-type "IELM Error"
+ wbuf (current-buffer))
+ (if (ielm-is-whitespace-or-comment (substring string pos))
+ ;; To correctly handle the ielm-local variables *,
+ ;; ** and ***, we need a temporary buffer to be
+ ;; current at entry to the inner of the next two let
+ ;; forms. We need another temporary buffer to exit
+ ;; that same let. To avoid problems, neither of
+ ;; these buffers should be alive during the
+ ;; evaluation of form.
+ (let* ((*1 *)
+ (*2 **)
+ (*3 ***)
+ (active-process (ielm-process))
+ (old-standard-output standard-output)
+ new-standard-output
+ ielm-temp-buffer)
+ (set-match-data ielm-match-data)
+ (save-excursion
+ (with-temp-buffer
+ (condition-case err
+ (unwind-protect
+ ;; The next let form creates default
+ ;; bindings for *, ** and ***. But
+ ;; these default bindings are
+ ;; identical to the ielm-local
+ ;; bindings. Hence, during the
+ ;; evaluation of form, the
+ ;; ielm-local values are going to be
+ ;; used in all buffers except for
+ ;; other ielm buffers, which override
+ ;; them. Normally, the variables *1,
+ ;; *2 and *3 also have default
+ ;; bindings, which are not overridden.
+ (let ((* *1)
+ (** *2)
+ (*** *3))
+ (when (eq standard-output t)
+ (setf new-standard-output
+ (ielm-standard-output-impl
+ active-process))
+ (setf standard-output new-standard-output))
+ (kill-buffer (current-buffer))
+ (set-buffer wbuf)
+ (setq result
+ (eval form lexical-binding))
+ (setq wbuf (current-buffer))
+ (setq
+ ielm-temp-buffer
+ (generate-new-buffer " *ielm-temp*"))
+ (set-buffer ielm-temp-buffer))
+ (when ielm-temp-buffer
+ (kill-buffer ielm-temp-buffer))
+ (when (eq new-standard-output standard-output)
+ (ignore-errors
+ (funcall standard-output t))
+ (setf standard-output old-standard-output)))
+ (error (setq result (error-message-string err))
+ (setq error-type "Eval error"))
+ (quit (setq result "Quit during evaluation")
+ (setq error-type "Eval error")))))
+ (setq ielm-match-data (match-data)))
+ (setq error-type "IELM error")
+ (setq result "More than one sexp in input"))))