From 751f1707f009c714dbfe047ef43443a5c0c3df89 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 16 Aug 2021 13:20:35 +0200 Subject: Add new functions to replace strings/regexp in a region * doc/lispref/searching.texi (Search and Replace): Document them. * lisp/subr.el (replace-string-in-region) (replace-regexp-in-region): New functions. * lisp/emacs-lisp/shortdoc.el (regexp, buffer): Mention them. --- lisp/emacs-lisp/shortdoc.el | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index 1b0fbfdf715..7d4a69f42a9 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -700,6 +700,8 @@ There can be any number of :example/:result elements." (match-substitute-replacement :no-eval (match-substitute-replacement "new") :eg-result "new") + (replace-regexp-in-region + :no-value (replace-regexp-in-region "[0-9]+" "Num \\&")) "Utilities" (regexp-quote :eval (regexp-quote "foo.*bar")) @@ -894,6 +896,10 @@ There can be any number of :example/:result elements." :no-value (erase-buffer)) (insert :no-value (insert "This string will be inserted in the buffer\n")) + (subst-char-in-region + :no-eval "(subst-char-in-region (point-min) (point-max) ?+ ?-)") + (replace-string-in-region + :no-value (replace-string-in-region "foo" "bar")) "Locking" (lock-buffer :no-value (lock-buffer "/tmp/foo")) -- cgit v1.2.3