all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: forward-sexp and quote
Date: 20 Jan 2003 02:52:32 +0100	[thread overview]
Message-ID: <87k7h0fuzj.fsf@thalassa.informatimago.com> (raw)



(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"


(progn
  (find-file "*bug*")
  (emacs-lisp-mode)
  (erase-buffer)
  (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)
before=2
after =4   BUG!


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


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


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



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

             reply	other threads:[~2003-01-20  1:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-20  1:52 Pascal Bourguignon [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-20  1:33 forward-sexp and quote Pascal Bourguignon
2003-01-21 18:17 ` Richard Stallman

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=87k7h0fuzj.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /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.