summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cl-lib.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2025-03-28 01:01:17 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2025-03-29 17:49:49 -0400
commit1d07a6d7e34677be1653b1d4d464ff00cabfa102 (patch)
tree9f27c30bd71b3ab9f7f5ed14e31f66e6b0fa85a6 /lisp/emacs-lisp/cl-lib.el
parent468c2aebae0ee13273f4b06e92f4188c4c46d2b3 (diff)
downloademacs-1d07a6d7e34677be1653b1d4d464ff00cabfa102.tar.gz
emacs-1d07a6d7e34677be1653b1d4d464ff00cabfa102.tar.bz2
emacs-1d07a6d7e34677be1653b1d4d464ff00cabfa102.zip
Use `replace-region-contents` to replace insert+delete
* lisp/minibuffer.el (completion--replace): * lisp/emacs-lisp/cl-lib.el (cl--set-buffer-substring): * lisp/subr.el (replace-string-in-region): Use `replace-region-contents` instead of insert+delete. * lisp/help-fns.el (help-fns--signature): Use `replace-region-contents` instead of `cl--set-buffer-substring`. * lisp/language/japan-util.el (japanese-replace-region): Rewrite using `replace-region-contents` and mark obsolete. (japanese-katakana-region, japanese-hankaku-region): Use `replace-region-contents` instead. * lisp/progmodes/flymake-proc.el (flymake-proc--replace-region): Rewrite using `replace-region-contents` and mark obsolete. (flymake-proc--check-patch-master-file-buffer): Use `replace-region-contents` instead.
Diffstat (limited to 'lisp/emacs-lisp/cl-lib.el')
-rw-r--r--lisp/emacs-lisp/cl-lib.el8
1 files changed, 3 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 4208160bd12..4645b4dffb1 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -154,12 +154,10 @@ to an element already in the list stored in PLACE.
`(setq ,place (cl-adjoin ,x ,place ,@keys)))
`(cl-callf2 cl-adjoin ,x ,place ,@keys)))
-(defun cl--set-buffer-substring (start end val)
+(defun cl--set-buffer-substring (start end val &optional inherit)
"Delete region from START to END and insert VAL."
- (save-excursion (delete-region start end)
- (goto-char start)
- (insert val)
- val))
+ (replace-region-contents start end val 0 nil inherit)
+ val)
(defun cl--set-substring (str start end val)
(if end (if (< end 0) (incf end (length str)))