From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ren Victor Newsgroups: gmane.emacs.bugs Subject: bug#42424: 27.0.90; replace-match: point is NOT left at the end of replacement Date: Sun, 19 Jul 2020 13:50:51 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000006ed3d005aac4fd8c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21596"; mail-complaints-to="usenet@ciao.gmane.io" To: 42424@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 19 07:53:19 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jx2GF-0005XA-It for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Jul 2020 07:53:19 +0200 Original-Received: from localhost ([::1]:39448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jx2GD-000300-Lq for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Jul 2020 01:53:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jx2Fz-0002zf-1Q for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 01:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jx2Fy-0000YH-OE for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 01:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jx2Fy-0001dT-Lq for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 01:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ren Victor Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Jul 2020 05:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42424 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15951379316228 (code B ref -1); Sun, 19 Jul 2020 05:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jul 2020 05:52:11 +0000 Original-Received: from localhost ([127.0.0.1]:59868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jx2F9-0001cO-Bh for submit@debbugs.gnu.org; Sun, 19 Jul 2020 01:52:11 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jx2F7-0001cG-Sl for submit@debbugs.gnu.org; Sun, 19 Jul 2020 01:52:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jx2F7-0002w0-KD for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 01:52:09 -0400 Original-Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:34751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jx2F5-0000WC-Kq for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 01:52:09 -0400 Original-Received: by mail-io1-xd32.google.com with SMTP id q74so14431921iod.1 for ; Sat, 18 Jul 2020 22:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hluyL3EFDNOIPxxJBZ9RlYB4uvv+Fm0elca/nTOA9CQ=; b=oaPEre84GoyiyYTc/Sa4L8wjUlX0v79xkdLV5tpZ0Hi4SZj0od3oz9uxpF6hQd6HHE dfnuGBX1MiuLiqoFtEfQTVVsKbPwwZlTQxlJ1eDasZ80Qa4ATxeclXS5TcBnEUJYp92h fWBJ8ztXOnLJF9L9fKqF7quwCR+Zq48gT5BAyoBvkTPgsdyrq9ZgkvuJjILhtHrKW0wM IQTiv4eA0aDZ57Jx2WtbhL1qE06vntg9QGqxv1PU1Eq5fj4PdwpvMD/7RbAft/MGFPz9 PzEo2XxxeQ+rKteTKvWvDdzgnJ/iHmWzhxKKR/RpWnTInxULQ8CKsGzCIf5Zm/58rES7 fL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hluyL3EFDNOIPxxJBZ9RlYB4uvv+Fm0elca/nTOA9CQ=; b=gZPzNfSmoHl2gWrjgi0Agl2fLQg1wabM41P8WWS9QNEthUONmE+NqpKlW+6nOBpMkA jhSnXPIds2sZKpr9AtVIqgL0gy4ZUzTiyfh2h81WIGoiLlk0O6qNjRKDWKy/JeH+I0dG YCedYTUrXOvW5cVSxQrhpT6Pq3HJyXrtUgW7Nes1rI+dVRmGa+6SPb1YKJuBGdlaCNoO GCJWInAWj6YxiVnH28j5Dm2TgBLn+3j0D5J7lcRXw2W9lhuEuMBDgvwf7sJpBtdL/kNP wQN9+UsXXpVfA61uazizOPeBKzhvxvUcfnoy/KbX/21zywcFcexl7ZwUhRAh0ed/fyym c+oA== X-Gm-Message-State: AOAM531iBNc7tRQlWR+cTlsObUiCeBKaT9Or+FdovBNAFqz2rfZyETPV JBFvDnA8H/egLYLfdvG12/Hccbkve7J/mW7UPsI4xNlY X-Google-Smtp-Source: ABdhPJwSdhcIhlJB5sA2OksIUgDo9N0kIYvjdiKUAbaypt9iL/XQqSoPnQi2fPtBQqQ6P+fYc864bPt76Iwz7WlZs4w= X-Received: by 2002:a05:6602:1491:: with SMTP id a17mr16981363iow.198.1595137925721; Sat, 18 Jul 2020 22:52:05 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::d32; envelope-from=victorhge@gmail.com; helo=mail-io1-xd32.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:183208 Archived-At: --0000000000006ed3d005aac4fd8c Content-Type: text/plain; charset="UTF-8" I attach an ert case to show the recipe. This issue happens when modification hooks modify the text before the end of replacement text. `replace-match' calls `replace_range' to do the actual replacement, which can trigger modification hooks. Before calling `replace_range', the position of the end of replacement is saved. After `replace_range', the point is moved to the saved position. But the end of replacement might be changed inside of `replace_range'. So the final movement of point may end up to a wrong place. Other types of modification (insert or delete) do not have this issue. `point' is adjusted before running modification hooks. In `replace_range', the point is also relocated. I am not sure why it has to be moved again just before returning from `replace-match'. This is not a new issue. It is in Emacs24 at least. In GNU Emacs 27.0.90 (build 1, x86_64-pc-cygwin) of 2020-03-04 built on moufang2 Repository revision: afff43a72e96fcccabe77ff63226cddd540e068d Repository branch: master Windowing system distributor 'Microsoft Corp.', version 10.0.19041 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Quit ert next-line: End of buffer [3 times] test-replace-match Ran 1 tests, 0 results were as expected, 1 unexpected next-line: End of buffer previous-line: Beginning of buffer [13 times] previous-line: Beginning of buffer Configured using: 'configure --srcdir=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/src/emacs-27.0.90 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/emacs --htmldir=/usr/share/doc/emacs/html -C --with-w32 'CFLAGS=-ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/build=/usr/src/debug/emacs-27.0.90-1 -fdebug-prefix-map=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/src/emacs-27.0.90=/usr/src/debug/emacs-27.0.90-1' CPPFLAGS= LDFLAGS=' Configured features: XPM JPEG TIFF GIF PNG SOUND DBUS GLIB NOTIFY GFILENOTIFY ACL GNUTLS LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS XIM MODULES THREADS JSON PDUMPER LCMS2 GMP Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq cl-extra seq byte-opt bytecomp byte-compile cconv cl-macs gv ert pp ewoc debug backtrace help-mode find-func vc-git diff-mode easymenu easy-mmode cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind gfilenotify w32 lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 62659 8699) (symbols 48 7750 1) (strings 32 21627 1406) (string-bytes 1 668356) (vectors 16 12971) (vector-slots 8 156156 9450) (floats 8 40 94) (intervals 56 307 1) (buffers 1000 14)) --0000000000006ed3d005aac4fd8c Content-Type: application/octet-stream; name="test_replace_match.el" Content-Disposition: attachment; filename="test_replace_match.el" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kcsnspgk0 KHJlcXVpcmUgJ2VydCkKCihlcnQtZGVmdGVzdCB0ZXN0LXJlcGxhY2UtbWF0Y2ggKCkKICAiVGVz dCBmb3IgYnVnLiIKICAobGV0ICgoY2hlY2stcG9pbnQgbmlsKQoJKG92LXNldCBuaWwpKQogICAg KHdpdGgtdGVtcC1idWZmZXIKICAgICAgKGluc2VydCAiYSBhYmMiKQogICAgICAoc2V0cSBvdi1z ZXQgKG1ha2Utb3ZlcmxheSAzIDUpKQogICAgICAob3ZlcmxheS1wdXQKCSAgIG92LXNldCAnbW9k aWZpY2F0aW9uLWhvb2tzCgkgICAobGlzdCAobGFtYmRhIChvIGFmdGVyICZyZXN0IF9hcmdzKQoJ CQkgICAod2hlbiBhZnRlcgoJCQkJIChsZXQgKChpbmhpYml0LW1vZGlmaWNhdGlvbi1ob29rcyB0 KSkKCQkJCSAgIChzYXZlLWV4Y3Vyc2lvbgoJCQkJCSAoZ290by1jaGFyIDIpCgkJCQkJIChpbnNl cnQgImJjZCIpKSkpKSkpCiAgICAgIChnb3RvLWNoYXIgMykKCSAgKGlmIChzZWFyY2gtZm9yd2Fy ZCAiYmMiKQoJCSAgKHJlcGxhY2UtbWF0Y2ggImJjZCIpKQogICAgICAoc2hvdWxkIChlcSAocG9p bnQpIDEwKSkpKSkK --0000000000006ed3d005aac4fd8c--