all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: TomSW <tom.weissmann@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: TERRIBLE ERROR :: Invalid search bound - wrong side of point
Date: Fri, 3 Jul 2009 00:47:51 -0700 (PDT)	[thread overview]
Message-ID: <675ce6e5-7321-483a-bbc0-7a9d8211dfdd@h11g2000yqb.googlegroups.com> (raw)
In-Reply-To: ebd783c0-345e-4f6d-a967-ad225dc0a9c2@y7g2000yqa.googlegroups.com

On Jul 3, 1:16 am, bolega <gnuist...@gmail.com> wrote:
> I am doing a very simple and trivial thing that you often do in bash
> using sed. Replace the end of the line by a token such as #.
>
> I loath to use newline which is a break in emacs since it probably
> does not accept \n.

It does.

> I only want to replace this on one line such as the current line. I
> could narrow to the line but is it really necessary ? Cant I just
> specify the limits in replace-regexp ? Either there is something
> seriously wrong with my understanding of emacs so I must pursue this
> for the sake of learning.

If you specify the limits of a replace operation you normally ensure
that the replacements don't add characters to the region being
changed. Otherwise there is a chance that the replacements will push
point beyond the end limit and you will get the error "Invalid search
bound". Narrowing means you don't need to worry about this.

Generally you should also avoid using replace-regexp in a program (as
explained in the documentation). Since you only want to do one
replacement, all you need is:

 (save-excursion
    (when (re-search-forward "$" nil :noerr)
      (replace-match "#")))

or even:

 (save-excursion
    (goto-char (line-end-position))
    (insert "#"))

regards,
Tom SW


      parent reply	other threads:[~2009-07-03  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-02 23:16 TERRIBLE ERROR :: Invalid search bound - wrong side of point bolega
2009-07-02 23:35 ` bolega
2009-07-03  3:42 ` Pillsy
2009-07-03  4:46   ` bolega
2009-07-03  7:16     ` Thien-Thi Nguyen
2009-07-03  7:47 ` TomSW [this message]

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

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

  git send-email \
    --in-reply-to=675ce6e5-7321-483a-bbc0-7a9d8211dfdd@h11g2000yqb.googlegroups.com \
    --to=tom.weissmann@gmail.com \
    --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.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.