- (if (not (ielm-is-whitespace ielm-string))
- (progn
- (condition-case err
- (let (rout)
- (setq rout (read-from-string ielm-string))
- (setq ielm-form (car rout))
- (setq ielm-pos (cdr rout)))
- (error (setq ielm-result (error-message-string err))
- (setq ielm-error-type "Read error")))
- (if ielm-error-type nil
- ;; 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 (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))
- (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"))))
-
- ;; If the eval changed the current buffer, mention it here
- (if (eq ielm-wbuf ielm-working-buffer) nil
- (message "current buffer is now: %s" ielm-wbuf)
- (setq ielm-working-buffer ielm-wbuf))
-
- (goto-char ielm-pmark)
- (if (not ielm-error-type)
- (condition-case err
- ;; Self-referential objects cause loops in the printer, so
- ;; trap quits here. May as well do errors, too
- (setq ielm-output (concat ielm-output (pp-to-string ielm-result)))
- (error (setq ielm-error-type "IELM Error")
- (setq ielm-result "Error during pretty-printing (bug in pp)"))
- (quit (setq ielm-error-type "IELM Error")
- (setq ielm-result "Quit during pretty-printing"))))
- (if ielm-error-type
- (progn
- (if ielm-noisy (ding))
- (setq ielm-output (concat ielm-output "*** " ielm-error-type " *** "))
- (setq ielm-output (concat ielm-output ielm-result)))
- ;; There was no error, so shift the *** values
- (setq *** **)
- (setq ** *)
- (setq * ielm-result))
- (setq ielm-output (concat ielm-output "\n"))))
+ (unless (ielm-is-whitespace-or-comment ielm-string)
+ (condition-case err
+ (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))
+ (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"))))
+
+ ;; If the eval changed the current buffer, mention it here
+ (unless (eq ielm-wbuf ielm-working-buffer)
+ (message "current buffer is now: %s" ielm-wbuf)
+ (setq ielm-working-buffer ielm-wbuf))
+
+ (goto-char ielm-pmark)
+ (unless ielm-error-type
+ (condition-case err
+ ;; Self-referential objects cause loops in the printer, so
+ ;; trap quits here. May as well do errors, too
+ (setq ielm-output (concat ielm-output (pp-to-string ielm-result)))
+ (error (setq ielm-error-type "IELM Error")
+ (setq ielm-result "Error during pretty-printing (bug in pp)"))
+ (quit (setq ielm-error-type "IELM Error")
+ (setq ielm-result "Quit during pretty-printing"))))
+ (if ielm-error-type
+ (progn
+ (when ielm-noisy (ding))
+ (setq ielm-output (concat ielm-output "*** " ielm-error-type " *** "))
+ (setq ielm-output (concat ielm-output ielm-result)))
+ ;; There was no error, so shift the *** values
+ (setq *** **)
+ (setq ** *)
+ (setq * ielm-result))
+ (setq ielm-output (concat ielm-output "\n")))