* elisp search-forward problem - function stops on search failed error
@ 2013-04-11 11:24 acomber
2013-04-11 12:35 ` Tassilo Horn
2013-04-11 12:48 ` Andreas Röhler
0 siblings, 2 replies; 3+ messages in thread
From: acomber @ 2013-04-11 11:24 UTC (permalink / raw)
To: Help-gnu-emacs
I wrote a function to replace tab characters with a string as in:
(defun do-cols ()
"convert tab char to html td delim"
(interactive)
(goto-char (point-min))
(while (search-forward "\t")
(insert "
")
)
)
which works fine but on finishing I see in the command window: Search
failed: " "
I think that when this error occurs the lisp function stops running.
That doesn't matter for simple use of do-cols but I want to call the
function from a bigger lisp function and I think if this error occurs
then the calling lisp function stops processing.
so anyway, I changed the function like this:
(defun do-cols ()
"convert tab char to html td delim"
(interactive)
(goto-char (point-min))
(while (search-forward "\t", nil, t)
(insert "
")
)
)
But this function does nothing, get error:
Symbol's value as variable is void: \,
How can I fix do-cols so it actually works and will allow a calling
function to continue processing to next line?
eg I might want:
(defun do-table ()
"convert word table to html"
(interactive)
(goto-char (point-min))
(do-cols)
(do-rows)
)
--
View this message in context: http://emacs.1067599.n5.nabble.com/elisp-search-forward-problem-function-stops-on-search-failed-error-tp283469.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: elisp search-forward problem - function stops on search failed error
2013-04-11 11:24 elisp search-forward problem - function stops on search failed error acomber
@ 2013-04-11 12:35 ` Tassilo Horn
2013-04-11 12:48 ` Andreas Röhler
1 sibling, 0 replies; 3+ messages in thread
From: Tassilo Horn @ 2013-04-11 12:35 UTC (permalink / raw)
To: help-gnu-emacs
acomber <deedexy@gmail.com> writes:
> (defun do-cols ()
> "convert tab char to html td delim"
> (interactive)
> (goto-char (point-min))
> (while (search-forward "\t")
> (insert "
> ")
> )
> )
>
> which works fine but on finishing I see in the command window: Search
> failed: " "
It doesn't replace, it adds something before (or after) the tabs.
> (while (search-forward "\t", nil, t)
>
> But this function does nothing, get error:
>
> Symbol's value as variable is void: \,
You don't write commas to separate arguments in funcalls (or items in
lists in general).
Bye,
Tassilo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: elisp search-forward problem - function stops on search failed error
2013-04-11 11:24 elisp search-forward problem - function stops on search failed error acomber
2013-04-11 12:35 ` Tassilo Horn
@ 2013-04-11 12:48 ` Andreas Röhler
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2013-04-11 12:48 UTC (permalink / raw)
To: help-gnu-emacs
Am 11.04.2013 13:24, schrieb acomber:
> I wrote a function to replace tab characters with a string as in:
>
> (defun do-cols ()
> "convert tab char to html td delim"
> (interactive)
> (goto-char (point-min))
> (while (search-forward "\t")
> (insert "
> ")
> )
> )
>
> which works fine but on finishing I see in the command window: Search
> failed: " "
>
...
(defun do-cols ()
"convert tab char to WHATEVER"
(interactive "*")
(goto-char (point-min))
(while (search-forward "\t" nil t)
(replace-match "BlahBlub")))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-11 12:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 11:24 elisp search-forward problem - function stops on search failed error acomber
2013-04-11 12:35 ` Tassilo Horn
2013-04-11 12:48 ` Andreas Röhler
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).