From 2db0393fd72a03bf6f52d9ed0d9d250ee142e770 Mon Sep 17 00:00:00 2001 From: Sam Steingold Date: Wed, 24 Jan 2001 21:00:29 +0000 Subject: (replace-in-string): Emacs 21 has `replace-regexp-in-string' - use it! --- ChangeLog | 3 +++ lisp/bbdb-snarf.el | 27 +++++++++++++++------------ 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 + * 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 -- cgit v1.2.3