summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-11-11 00:56:44 +0000
committerMiles Bader <miles@gnu.org>2007-11-11 00:56:44 +0000
commitf23d76bdefbd4c06e14d69e99e50d35ce91c8226 (patch)
treeded28d1da6df2d0135514bac83074f4ca1c9099a /lisp/subr.el
parente2d092da5980a7d05a5428074f8eb4925fa801e8 (diff)
parenta457417ee5ba797ab1c91d35ee957bb7a7f8d4b6 (diff)
downloademacs-f23d76bdefbd4c06e14d69e99e50d35ce91c8226.tar.gz
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index d48b5a130a6..16cb8913559 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2709,6 +2709,24 @@ STRING should be given if the last search was by `string-match' on STRING."
(buffer-substring-no-properties (match-beginning num)
(match-end num)))))
+
+(defun match-substitute-replacement (replacement
+ &optional fixedcase literal string subexp)
+ "Return REPLACEMENT as it will be inserted by `replace-match'.
+In other words, all back-references in the form `\\&' and `\\N'
+are substituted with actual strings matched by the last search.
+Optional FIXEDCASE, LITERAL, STRING and SUBEXP have the same
+meaning as for `replace-match'."
+ (let ((match (match-string 0 string)))
+ (save-match-data
+ (set-match-data (mapcar (lambda (x)
+ (if (numberp x)
+ (- x (match-beginning 0))
+ x))
+ (match-data t)))
+ (replace-match replacement fixedcase literal match subexp))))
+
+
(defun looking-back (regexp &optional limit greedy)
"Return non-nil if text before point matches regular expression REGEXP.
Like `looking-at' except matches before point, and is slower.