From: Bastien <bzg@altern.org>
To: emacs-devel@gnu.org
Subject: Re: 23.0.50; ielm doesn't handle comments
Date: Fri, 15 Feb 2008 00:41:14 +0000 [thread overview]
Message-ID: <87ir0rdpat.fsf@bzg.ath.cx> (raw)
In-Reply-To: <?fnord?m2ve4r9ri0.fsf@ID-97657.user.individual.net> (Lawrence Mitchell's message of "Thu, 14 Feb 2008 21:07:19 +0000")
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
Lawrence Mitchell <wence@gmx.li> writes:
> Bastien Guerry wrote:
>
>
> [...]
>
>
>>> (defun ielm-trim-comments (string)
>>> "Trim comments in STRING."
>>> (let ((pos (previous-single-property-change
>>> (length string) 'face string)))
>>> (if (eq (get-text-property pos 'face)
>>> 'font-lock-comment-face)
>>> (substring string 0 pos))))
>
> This breaks if the user doesn't use font-lock.
Right. I have come up with another solution, not relying on font-lock,
but this one doesn't allow the double-quote character in comments.
Please improve it if you can. If no objection/suggestion until next
week, I'll apply this one.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ieml.el.patch --]
[-- Type: text/x-diff, Size: 957 bytes --]
--- ielm.el.~1.58.~ 2008-01-08 20:44:50.000000000 +0000
+++ ielm.el 2008-02-15 00:35:37.000000000 +0000
@@ -304,6 +304,17 @@
"Return non-nil if STRING is all whitespace."
(or (string= string "") (string-match "\\`[ \t\n]+\\'" string)))
+(defun ielm-trim-comments (string)
+ "Trim comments out of STRING."
+ ;; FIXME: comments containing a double-quote character will not be
+ ;; recognized as comments. This is to allow sexp like "é".
+ (with-temp-buffer
+ (insert string)
+ (buffer-substring
+ (point-min)
+ (if (looking-back "[; \t]+[^\"]*" nil t)
+ (match-beginning 0) (point-max)))))
+
;;; Evaluation
(defun ielm-eval-input (ielm-string)
@@ -331,6 +342,8 @@
(progn
(condition-case err
(let (rout)
+ ;; Make sure to get rid of comments
+ (setq ielm-string (ielm-trim-comments ielm-string))
(setq rout (read-from-string ielm-string))
(setq ielm-form (car rout))
(setq ielm-pos (cdr rout)))
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
--
Bastien
next prev parent reply other threads:[~2008-02-15 0:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-14 0:14 23.0.50; ielm doesn't handle comments Adam Winiecki
2008-02-14 16:10 ` Lawrence Mitchell
2008-02-15 0:03 ` Richard Stallman
2008-02-14 18:11 ` Richard Stallman
2008-02-14 18:33 ` Bastien Guerry
2008-02-14 19:11 ` Reiner Steib
2008-02-14 20:01 ` Bastien Guerry
2008-02-14 21:07 ` Lawrence Mitchell
2008-02-15 0:41 ` Bastien [this message]
2008-02-15 8:49 ` Lawrence Mitchell
2008-02-15 14:27 ` Bastien Guerry
2008-02-15 16:35 ` Bastien Guerry
2008-02-15 19:44 ` Lawrence Mitchell
2008-02-16 16:21 ` Bastien
2008-02-16 17:40 ` Lawrence Mitchell
2008-02-16 18:17 ` Bastien Guerry
2008-02-16 23:11 ` Glenn Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ir0rdpat.fsf@bzg.ath.cx \
--to=bzg@altern.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.