[Top][All Lists]

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

forward-sexp and quote

From: Pascal Bourguignon
Subject: forward-sexp and quote
Date: 20 Jan 2003 02:52:32 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

(forward-sexp 1) eats quotes and backquotes, but (forward-sexp -1) doesn't.
That is, when there are spaces after the quote.
Which is unfortunate because the reader doesn't mind these spaces 
and reads correctly the quoted expression:

.' (a b c)  --(forward-sexp 1)--> ' (a b c). --(forward-sexp -1)--> ' .(a b c)

;; dot showing the point.

(show ' ( a b c))
==> (a b c)

The bug can be traced to scan-sexp which is a built-in.
(show (version))
==> "GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit)
 of 2002-10-26 on thalassa"

  (find-file "*bug*")
  (mapc (lambda (s)
          (let (before after end read-before read-after)
            (goto-char (point-max))
            (insert "\n")
            (setq before (point))
            (insert s)
            (setq end (point))
            (goto-char before)
            (setq read-before (read-from-string (buffer-substring (point) end)))
            (forward-sexp 1)
            (forward-sexp -1)
            (setq after (point))
            (setq read-after (read-from-string (buffer-substring (point) end)))
            (goto-char (point-max))
            (insert (format "\nread before: %S\n" read-before))
            (insert (format "read after : %S\n" read-after))
            (insert (format "before=%S\nafter =%S   %s\n\n" before after
                             (if (= before after) "" "BUG!")))))
        '("' (a b c)" "'(a b c)" "' abc" "'abc")))

' (a b c)
read before: ((quote (a b c)) . 9)
read after : ((a b c) . 7)
after =4   BUG!

'(a b c)
read before: ((quote (a b c)) . 8)
read after : ((quote (a b c)) . 8)
after =101   

' abc
read before: ((quote abc) . 5)
read after : (abc . 3)
after =209   BUG!

read before: ((quote abc) . 4)
read after : ((quote abc) . 4)
after =298   

__Pascal_Bourguignon__                   http://www.informatimago.com/
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie

reply via email to

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