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

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

Can't get replace-match to replace intended match-data


From: Jonas Jarnestrom
Subject: Can't get replace-match to replace intended match-data
Date: Sat, 29 Sep 2001 20:54:33 +0200 (MET DST)

This bug report will be sent to the Free Software Foundation,
 not to your local site managers!!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

In GNU Emacs 20.6.1 (sparc-sun-solaris2.6, X toolkit)
 of Fri Mar  3 2000 on iris
configured using `configure  --with-gcc --with-pop --with-x-toolkit=lucid 
--bindir=/usr/local/bin --libexecdir=/usr/local/libexec'

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

I have a file with a header like this:

#######################################################################
#
# Target: <cpmerge_dir>
# Doc: <bla bla bla bla>
#
# Type: <user config>
# File: <cpmerge_dir_0926.cs>
# Path: </homes/erajonj/.user_conf>
#
# Modified: <Sep 26 11:50 01 erajonj 222>
# Created:  <Sep 25 19:18 01 erajonj>
#
#######################################################################

I want to replace the contents in between the first brackets with the
function:

(defun cs-head-set-target ()
""
  (interactive)
    (goto-char (point-min))
    (and (re-search-forward "Target: +<\\(.*\\)>"  400 'noerr)
         (replace-match "perka" nil nil nil 1))
  )

After running the func above, the result is as follows:

#######################################################################
#
# Target: <perka <bla bla bla bla>
#
# Type: <user config>
# File: <cpmerge_dir_0926.cs>
# Path: </homes/erajonj/.user_conf>
#
# Modified: <Sep 26 11:50 01 erajonj 222>
# Created:  <Sep 25 19:18 01 erajonj>
#
#######################################################################

i.e. the line break and part of the doc field has been eaten up.
I have played with all the args to replace-match without lasting
success, as well as different search patterns. 
I have tried to get this straight for 2-3 days now but to no avail.
I have checked the match data over and over, and it looks right after
the call of re-search, but all the same the replacement goes into the
next line.
What on earth have I missed?

Best regards,
Jonas Jarnestrom, Stockholm Sweden



reply via email to

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