summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Steingold <sds@goems.com>2001-01-24 21:00:29 +0000
committerSam Steingold <sds@goems.com>2001-01-24 21:00:29 +0000
commit2db0393fd72a03bf6f52d9ed0d9d250ee142e770 (patch)
treed7105a4763a90fe919ccb9476ec6dcafc63d965e
parent888a09eb5d3dc354cb9f8d3122a4a3902096d66c (diff)
(replace-in-string): Emacs 21 has `replace-regexp-in-string' - use it!
-rw-r--r--ChangeLog3
-rw-r--r--lisp/bbdb-snarf.el27
2 files changed, 18 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index caa3a9c..d61d94b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2001-01-24 Sam Steingold <sds@gnu.org>
+ * lisp/bbdb-snarf.el (replace-in-string): Emacs 21 has
+ `replace-regexp-in-string' - use it!
+
* lisp/bbdb-merge.el (bbdb-merge-file): bugfix:
the parameter for `match-fun' is `rec', not `r'
diff --git a/lisp/bbdb-snarf.el b/lisp/bbdb-snarf.el
index f44928b..9af03fb 100644
--- a/lisp/bbdb-snarf.el
+++ b/lisp/bbdb-snarf.el
@@ -386,18 +386,21 @@ more details."
;;----------------------------------------------------------------------------
;; Emacs 20.3 seems to miss the function replace-in-string?
-(unless (boundp 'replace-in-string)
- ;; actually this is `dired-replace-in-string' slightly modified
- (defun replace-in-string (string regexp newtext &optional literal)
- ;; Replace REGEXP with NEWTEXT everywhere in STRING and return result.
- ;; NEWTEXT is taken literally---no \\DIGIT escapes will be recognized.
- (let ((result "") (start 0) mb me)
- (while (string-match regexp string start)
- (setq mb (match-beginning 0)
- me (match-end 0)
- result (concat result (substring string start mb) newtext)
- start me))
- (concat result (substring string start)))))
+(unless (fboundp 'replace-in-string)
+ (if (fboundp 'replace-regexp-in-string) ; defined in e21
+ (defun replace-in-string (string regexp newtext &optional literal)
+ (replace-regexp-in-string string regexp newtext nil literal))
+ ;; actually this is `dired-replace-in-string' slightly modified
+ (defun replace-in-string (string regexp newtext &optional literal)
+ ;; Replace REGEXP with NEWTEXT everywhere in STRING and return result.
+ ;; NEWTEXT is taken literally---no \\DIGIT escapes will be recognized.
+ (let ((result "") (start 0) mb me)
+ (while (string-match regexp string start)
+ (setq mb (match-beginning 0)
+ me (match-end 0)
+ result (concat result (substring string start mb) newtext)
+ start me))
+ (concat result (substring string start))))))
(defcustom bbdb-snarf-nice-real-name-regexp "[._,\t\n ]+"
"*Regexp matching string which `bbdb-snarf-nice-real-name' will replace by