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

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

Re: TERRIBLE ERROR :: Invalid search bound - wrong side of point


From: Pillsy
Subject: Re: TERRIBLE ERROR :: Invalid search bound - wrong side of point
Date: Thu, 2 Jul 2009 20:42:00 -0700 (PDT)
User-agent: G2/1.0

On Jul 2, 7:16 pm, bolega <gnuist...@gmail.com> wrote:
[...]
> 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.

You should probably try comp.emacs or gnu.help.emacs, too, since this
group focuses almost entirely on the Common Lisp dialect of Lisp.
Nonetheless, I'll take a stab at answering your question.

> I tried several variants:

> (replace-regexp "$" "#" nil (line-beginning-position) (line-end-
> position nil) )
> (replace-regexp "$" "#" nil (line-beginning-position) (+ (line-end-
> position nil) 1))

Well, one thing that works is to capture the text of the line as a
group, like so:

(replace-regexp "^\\(.*\\)$" "\\1#"
                  nil
                  (line-beginning-position)
                  (line-end-position))

However, if you just want to stick a character onto the end of the
line, why not just move the point there and insert the character
instead of using regexps?

(save-excursion (end-of-line) (insert "#"))

HTH,
Pillsy


reply via email to

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