unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: What is elisp idiom for continue until end of buffer
Date: Sat, 11 Aug 2012 00:12:01 +0800	[thread overview]
Message-ID: <87fw7u20by.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 1344609797798-261116.post@n5.nabble.com

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	other threads:[~2012-08-10 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 14:43 What is elisp idiom for continue until end of buffer acomber
2012-08-10 16:12 ` Eric Abrahamsen [this message]
2012-08-10 16:16   ` acomber

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fw7u20by.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).