help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: What is elisp idiom for continue until end of buffer


From: Eric Abrahamsen
Subject: Re: What is elisp idiom for continue until end of buffer
Date: Sat, 11 Aug 2012 00:12:01 +0800
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux)

On Fri, Aug 10 2012, acomber wrote:

> I created this elisp function
>
> (defun fmt-tbl () 
>   "format Word tables for wiki"
>   (interactive)
>   (goto-char (point-min))
>   (insert "{||-")
>  (while (search-forward "\t")
>     (delete-backward-char 1)
>     (insert "|")
>   )
>   (goto-char (point-min))
>   (while (search-forward "\n")
>     (insert "|-")
>   )
>   (goto-char (point-max))
>   (insert "|}")
> )
>
> Which fails at  (while (search-forward "\n").  I also tried 
>  (while (end-of-line)
>    (insert "|-")
>  )
>
> But that also didn't work.
>
> How can I repeatedly goto end of line on each line until EOF?

`search-forward' takes an optional *third* argument, NOERROR. First
(required) argument is the string to search for, second is a buffer
position to limit the search to (set to nil for whole buffer), and the
third should be set to 't' to keep the function from exploding when no
further matches are found.

Not once I have I used this function without setting NOERROR to 't'.

E

>
>
>
>
> --
> View this message in context: 
> http://emacs.1067599.n5.nabble.com/What-is-elisp-idiom-for-continue-until-end-of-buffer-tp261116.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.
>
>

-- 
GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.11)
 of 2012-08-06 on pellet




reply via email to

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