aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-07-31 17:44:43 +0200
committerLars Ingebrigtsen2021-07-31 17:44:43 +0200
commitf6c5a801efdad6cc7ed16ac0b1fa53599b84bc91 (patch)
tree733b465030587f28fc1dbf2970d646245802517d /test/src
parentc4239ec32c944e74252937bfc52e341f81b7a5a4 (diff)
downloademacs-f6c5a801efdad6cc7ed16ac0b1fa53599b84bc91.tar.gz
emacs-f6c5a801efdad6cc7ed16ac0b1fa53599b84bc91.zip
Adjust how `replace-match' runs modification hooks
* src/editfns.c (Fsubst_char_in_region) (Ftranslate_region_internal): * src/cmds.c (internal_self_insert): Update callers. * src/insdel.c (replace_range): Allow inhibiting signal_after_change/update_compositions. * src/lisp.h: Update. * src/search.c (Freplace_match): Run the modification hooks at the end instead of before adjusting point (bug#42424).
Diffstat (limited to 'test/src')
-rw-r--r--test/src/search-tests.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/src/search-tests.el b/test/src/search-tests.el
new file mode 100644
index 00000000000..b7b4ab9a8ff
--- /dev/null
+++ b/test/src/search-tests.el
@@ -0,0 +1,42 @@
1;;; search-tests.el --- tests for search.c functions -*- lexical-binding: t -*-
2
3;; Copyright (C) 2015-2016, 2018-2021 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23
24(ert-deftest test-replace-match-modification-hooks ()
25 (let ((ov-set nil))
26 (with-temp-buffer
27 (insert "1 abc")
28 (setq ov-set (make-overlay 3 5))
29 (overlay-put
30 ov-set 'modification-hooks
31 (list (lambda (o after &rest _args)
32 (when after
33 (let ((inhibit-modification-hooks t))
34 (save-excursion
35 (goto-char 2)
36 (insert "234")))))))
37 (goto-char 3)
38 (if (search-forward "bc")
39 (replace-match "bcd"))
40 (should (= (point) 10)))))
41
42;;; search-tests.el ends here