[ cl-cookbook-Support Requests-612276 ] replace-in-string not found

"SourceForge.net" <[email protected]> Sun, 09 Mar 2003 07:54:51 -0800
Newsgroups gmane.lisp.cookbook
Message-ID <[email protected]>
Support Requests item #612276, was opened at 2002-09-20 15:55
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=447473&aid=612276&group_id=46815

Category: None
Group: None
Status: Open
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: replace-in-string not found

Initial Comment:
hello,

in completer.el, the function completer-file calls the 
function replace-in-string.  neither emacs nor i can find 
its definition.  can you help?  i'm running gnu emacs 
version 21.2.1

thanks,

-geo

[email protected]

----------------------------------------------------------------------

>Comment By: Jeff Caldwell (jdcal)
Date: 2003-03-09 10:54

Message:
Logged In: YES 
user_id=727455

Add to .emacs

; From 
;  http://www.mail-archive.com/[email protected]/msg05272.html

(if (not (fboundp 'replace-in-string))
    ;;; copied from gnus-util (Oort)
    (defun replace-in-string (string regexp newtext
&optional literal)
      (let ((start 0) tail)
        (while (string-match regexp string start)
          (setq tail (- (length string) (match-end 0)))
          (setq string (replace-match newtext nil literal
string))
          (setq start (1- (- (length string) tail)))))
      string))

The 1- in the final setq start puts start at the last
character of the replacement string. Trying to sub a char
with itself loops. I haven't run into trouble with (setq
start (- (length string) tail)) but ymmv. I haven't done the
grand tour considering everything that might happen with a
sub'd regexp. I think the if-not-boundp is just there in
case the original function pops up from somewhere. If your
.emacs is settled and you're going to depend upon this
version of replace-in-string, you probably can remove the if.

Jeff Caldwell

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=447473&aid=612276&group_id=46815


-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com