emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 23.0.50; ielm doesn't handle comments


From: Lawrence Mitchell
Subject: Re: 23.0.50; ielm doesn't handle comments
Date: Thu, 14 Feb 2008 16:10:16 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Adam Winiecki wrote:
> --text follows this line--

> while using ielm in emacs 23.0.50 and emacs 22.1, any code run in ielm
> with a comment will cause ielm to fail:

> ELISP> (message "hi") ;;ouch
> *** IELM error ***  More than one sexp in input

> ELISP> (setq foo 1) ;;ouch
> *** IELM error ***  More than one sexp in input

This didn't work in 21 either.  The problem is that
ielm-eval-input considers a comment on the end of the final input
line to be a second form (it isn't ignore like whitespace is).

The following patch, while perhaps not TRT fixes this problem.



diff --git a/lisp/ielm.el b/lisp/ielm.el
index 764e78b..8a77ba8 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -300,9 +300,9 @@ simply inserts a newline."
 
 ;;; Utility functions
 
-(defun ielm-is-whitespace (string)
+(defun ielm-is-whitespace-or-comment (string)
   "Return non-nil if STRING is all whitespace."
-  (or (string= string "") (string-match "\\`[ \t\n]+\\'" string)))
+  (or (string= string "") (string-match "\\`[ \t\n]+\\(?:;.*\\)*\\'" string)))
 
 ;;; Evaluation
 
@@ -327,7 +327,7 @@ simply inserts a newline."
        (ielm-output    "")             ; result to display
        (ielm-wbuf ielm-working-buffer) ; current buffer after evaluation
        (ielm-pmark (ielm-pm)))
-    (if (not (ielm-is-whitespace ielm-string))
+    (if (not (ielm-is-whitespace-or-comment ielm-string))
        (progn
          (condition-case err
              (let (rout)
@@ -342,7 +342,8 @@ simply inserts a newline."
                (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))
+             (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


ChangeLog entry:

Lawrence Mitchell <address@hidden>

         * ielm.el (ielm-is-whitespace): Remove.
         (ielm-is-whitespace-or-comment): New function.
         (ielm-eval-input): Use it.

-- 
Lawrence Mitchell <address@hidden>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]