unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* looping through re-seach-forward gives error
@ 2016-03-20 21:48 jenia.ivlev
  2016-03-20 22:13 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: jenia.ivlev @ 2016-03-20 21:48 UTC (permalink / raw)
  To: help-gnu-emacs

This program aims to restore the guile REPL session dump (see input file).

When I added the while loop, ELISP stated giving me this error when the
end of the file is reacher:

`Scan error: "Containg expression end prematurely", 715, 716`

Can someone please tell me what the problem is?

This is the program:

PROGRAM
=======
    (defun retore-guile-session()
      (interactive)
      (save-excursion 
      (while (progn (re-search-forward "scheme@(guile-user)" (point-max) t))
         (append-to-buffer "scratch" (find-start-of-sexp)
                                     (find-end-of-sexp)))))
    
    
    
    (defun find-start-of-sexp ()
    
       (re-search-forward "(" (point-max) t)
       (backward-char) 
       (point-marker))
    
    
    (defun find-end-of-sexp ()
      (forward-sexp)
      (point-marker))

And this is the input file?

INPUT FILE (to use it just visit it and run the program)
==========

    GNU Guile 2.0.11
    Copyright (C) 1995-2014 Free Software Foundation, Inc.
    
    Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
    This program is free software, and you are welcome to redistribute it
    under certain conditions; type `,show c' for details.
    
    Enter `,help' for help.
    scheme@(guile-user)> 
    scheme@(guile-user)> 
    scheme@(guile-user)> 
    scheme@(guile-user)> (+ 1 2)
    $2 = 3
    scheme@(guile-user)> 
    scheme@(guile-user)> 
    scheme@(guile-user)> (+1 2)
    ERROR: In procedure 1:
    ERROR: Wrong type to apply: 1
    
    Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
    scheme@(guile-user) [1]> 
    scheme@(guile-user) [1]> 
    scheme@(guile-user) [1]> (+ 1 2 (*
    				 2 3))
    $3 = 9
    scheme@(guile-user) [1]> 


Can someone please tell me, why is ELSIP giving me error `Scan error:
"Containg expression end prematurely", 715, 716` when the while loop
reaches the end of the file?

Thanks in advance




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

* RE: looping through re-seach-forward gives error
  2016-03-20 21:48 looping through re-seach-forward gives error jenia.ivlev
@ 2016-03-20 22:13 ` Drew Adams
  2016-03-20 22:21   ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2016-03-20 22:13 UTC (permalink / raw)
  To: jenia.ivlev, help-gnu-emacs

>     (defun find-start-of-sexp ()
>        (re-search-forward "(" (point-max) t)
>        (backward-char)
>        (point-marker))

What happens if (re-search-forward "(" (point-max) t) returns nil?

>     (defun find-end-of-sexp ()
>       (forward-sexp)
>       (point-marker))

What happens if (forward-sexp) has a problem?



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

* Re: looping through re-seach-forward gives error
  2016-03-20 22:13 ` Drew Adams
@ 2016-03-20 22:21   ` Michael Heerdegen
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Heerdegen @ 2016-03-20 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

> >     (defun find-start-of-sexp ()
> >        (re-search-forward "(" (point-max) t)
> >        (backward-char)
> >        (point-marker))
>
> What happens if (re-search-forward "(" (point-max) t) returns nil?
>
> >     (defun find-end-of-sexp ()
> >       (forward-sexp)
> >       (point-marker))
>
> What happens if (forward-sexp) has a problem?

Also: what happens when there are prompts which are directly followed by
another prompt?

I suggest to use Edebug to see what's going on.  Just instrument your
stuff (C-u C-M-x), start your program, and hit SPC, SPC, ... to see
what's going on.


Michael.




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

end of thread, other threads:[~2016-03-20 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-20 21:48 looping through re-seach-forward gives error jenia.ivlev
2016-03-20 22:13 ` Drew Adams
2016-03-20 22:21   ` Michael Heerdegen

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).