unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* forward-sexp and quote
@ 2003-01-20  1:33 Pascal Bourguignon
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Bourguignon @ 2003-01-20  1:33 UTC (permalink / raw)




(forward-sexp 1) eats quotes and backquotes, but (forward-sexp -1) doesn't.

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

(dot showing the point).

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 (point))
                after)
            (goto-char (point-max))
            (insert "\n")
            (insert s)
            (goto-char before)
            (forward-sexp 1)
            (forward-sexp -1)
            (setq after (point))
            (goto-char (point-max))
            (insert (format "\nbefore=%S\nafter =%S\n\n" before after))))
        '("' (a b c)" "'(a b c)")))


' (a b c)
before=1
after =4


'(a b c)
before=31
after =32


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* forward-sexp and quote
@ 2003-01-20  1:52 Pascal Bourguignon
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Bourguignon @ 2003-01-20  1:52 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-20  1:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-20  1:52 forward-sexp and quote Pascal Bourguignon
  -- strict thread matches above, loose matches on Subject: below --
2003-01-20  1:33 Pascal Bourguignon

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).