GNU bug report logs - #38316
26.1; Undo with undo-inhibit-record-point set doesn't restore unmodified state

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Braun Gábor <braungb88@HIDDEN>; dated Thu, 21 Nov 2019 21:19:04 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Nov 2019 21:18:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 21 16:18:34 2019
Received: from localhost ([127.0.0.1]:53404 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iXtqR-000334-L1
	for submit <at> debbugs.gnu.org; Thu, 21 Nov 2019 16:18:32 -0500
Received: from lists.gnu.org ([209.51.188.17]:47970)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <braungb88@HIDDEN>) id 1iXtqQ-00032u-3j
 for submit <at> debbugs.gnu.org; Thu, 21 Nov 2019 16:18:30 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48965)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <braungb88@HIDDEN>) id 1iXtqO-0004ab-Gz
 for bug-gnu-emacs@HIDDEN; Thu, 21 Nov 2019 16:18:29 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
 FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,URIBL_BLOCKED autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <braungb88@HIDDEN>) id 1iXtqM-0002Lc-Uh
 for bug-gnu-emacs@HIDDEN; Thu, 21 Nov 2019 16:18:28 -0500
Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:38821)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <braungb88@HIDDEN>) id 1iXtqM-0002K8-Nx
 for bug-gnu-emacs@HIDDEN; Thu, 21 Nov 2019 16:18:26 -0500
Received: by mail-wr1-x434.google.com with SMTP id i12so6191647wro.5
 for <bug-gnu-emacs@HIDDEN>; Thu, 21 Nov 2019 13:18:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=cWB/kRlz9cAoz7RZygYWkez7WQ0c00HY3ebAL3tTl3U=;
 b=OEyIeh1gBY1BcADKKOIuFXZkKv9r4+h0mCQP1ZKjAB/sC6xCD0+QTSSWMHzyRxAdKo
 aEJeBEnuKVLXat7PK06T9XcGFwJX15eHDeTjQChogsu5nKicxz6yDhMwzaqtipjthO2f
 YGWSPoI0JYiZEn1VlG3XGU1FwFMTcBDlHSGWyDU6d834XhL1W6mgj3GXLR86+xnw0u2K
 cYzUIg5Sef17AGFs9MDmq+sPOlKuhzEx/gEk6vSO6sVSsthIdavEgR/MJktPSvXz9kKG
 zxQ/IabsMS9nlrWK+ZYuXTSM5Qgvnb5Wzo8rfsW020CtboaA/Zdqy16/vIuIeVt6aefh
 JPXA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=cWB/kRlz9cAoz7RZygYWkez7WQ0c00HY3ebAL3tTl3U=;
 b=raqebMVsawELzd5i5FR33hSUPGdzQ3rqIusGm6DZK/KH20WpY3+Pake1u6tGf4PqUD
 4wqnKVcIFnMZKq5OhdIDg+928mPEyE4l1u+xyThLX1yUGf2Jvv3U1e/U+G2ZicapkCoo
 u5n+gzzZfF9/o1s8Yw0cAgil2Xx6ZjGqbP83DTXbRl1x1MVg/FbDQwc8d6Hd7XKvQXXA
 GjHOkr1g/sSZ4uOKbfCPKE7kr2FQiQ8rRcwBrPNVBWQqEXqSUKknX6gA5w1NafgJNsNa
 hy9KwDV2VkNUxmfKM/G+VnhoMsNthWLYf6FmkltbPITDcpC9OTcLCaEN+vejpNQ0x44W
 Pcjw==
X-Gm-Message-State: APjAAAV7uouIvJrz4FnMlEToLrhZdinZ6vt/kIW5dmwjJECho/xKX74k
 zpWU2Gc+32q8dU8Sw8k+1SrGGSBB
X-Google-Smtp-Source: APXvYqzT+Olo778M9fbSb2sXBSiACTyY8K0Ni7VTJPF+4d6Kxf+/SbpmG8t7QHJuLz9LuJf9CZiYMw==
X-Received: by 2002:a5d:414a:: with SMTP id c10mr14514121wrq.100.1574371104231; 
 Thu, 21 Nov 2019 13:18:24 -0800 (PST)
Received: from gabor.localnet (254C5777.nat.pool.telekom.hu. [37.76.87.119])
 by smtp.gmail.com with ESMTPSA id 17sm923911wmg.19.2019.11.21.13.18.22
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 Nov 2019 13:18:23 -0800 (PST)
From: Braun =?ISO-8859-1?Q?G=E1bor?= <braungb88@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 26.1;
 Undo with undo-inhibit-record-point set doesn't restore unmodified
 state
Date: Thu, 21 Nov 2019 22:18:21 +0100
Message-ID: <1681190.f0pj01Nb2o@gabor>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a00:1450:4864:20::434
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

1. Start Emacs:

emacs -Q --eval '(setq undo-inhibit-record-point t)'

I see the scratch buffer with -- in the modeline indicating it is not=20
modified.

2. Enter 'abc' in the scratch buffer: press keys a b c.

3. Press C-_.

The inserted 'abc' is deleted, but in the modeline I see ** indicating
that the buffer is modified.  The expectation is that the buffer is no
longer modified.


Do the same as above but start Emacs with 'emacs -Q', no additional
options.  Now after C-_ I see -- in the modeline indicating that the
buffer is not modified, as expected.


Discussion:

1. The value of buffer-undo-list is (as shown by C-h v buffer-undo-list)
in the first case

(nil
 (#("abc" 0 3
    (fontified t))
   . 146)
 (#<marker at 146 in *scratch*> . -3)
 nil
 (146 . 149)
 nil
 (1 . 146))

while in the second case

(nil
 (#("abc" 0 3
    (fontified t))
   . 146)
 (#<marker at 146 in *scratch*> . -3)
 nil
 (146 . 149)
 (t . 0)
 nil
 (1 . 146)
 (t . 0))


The only change I see is the additional (t . 0) entries in buffer-undo-
list.


2. The difference in buffer-undo-list is explained by the function
record_point in src/undo.c, which I include here in an abbreviated form
with ... denoting omissions:


static void
record_point (ptrdiff_t beg)
{
  /* Don't record position of pt when undo_inhibit_record_point holds. =20
*/
  if (undo_inhibit_record_point)
    return;
   =20
  ...
 =20
  /* If this is the first change since save, then record this.*/
  if (MODIFF <=3D SAVE_MODIFF)
    record_first_change ();

  /* We may need to record point ...*/
  if (at_boundary
      && point_before_last_command_or_undo !=3D beg
      && buffer_before_last_command_or_undo =3D=3D current_buffer )
    bset_undo_list (current_buffer,
		    Fcons (make_fixnum (point_before_last_command_or_undo),
			   BVAR (current_buffer, undo_list)));
}


here the call to record_first_change() is responsible for adding the
(t . ...)  entries.  Note that record_first_change() is called only if
undo-inhibit-record-point is nil regardles of whether point actually
gets recorded in buffer-undo-list (i.e. the condition of the last `if'
is true).

By the way, functions record_insert and record_delete seem to rely on
record_point adding necessary (t . ...) entries.  So these functions
never add (t . ...) entries when undo-inhibit-record-point is t,
and that's why they are missing in the first example above.

Best wishes,

     G=C3=A1bor


System information:

In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5)
 of 2019-09-23, modified by Debian built on x86-grnet-01
Windowing system distributor 'The X.Org Foundation', version=20
11.0.12004000
System Description:	Debian GNU/Linux 10 (buster)

Recent messages:
=46or information about GNU Emacs and the GNU system, type C-h C-a.
Undo!
Type C-x 1 to delete the help window, C-M-v to scroll help.

Configured using:
 'configure --build x86_64-linux-gnu --prefix=3D/usr
 --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib
 --localstatedir=3D/var/lib --infodir=3D/usr/share/info
 --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes
 --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site-
lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/
usr/share/emacs/site-lisp
 --with-sound=3Dalsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib
 --libexecdir=3D/usr/lib --localstatedir=3D/var/lib
 --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd
 --with-pop=3Dyes
 --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site-
lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/
usr/share/emacs/site-lisp
 --with-sound=3Dalsa --without-gconf --with-mailutils --with-x=3Dyes
 --with-x-toolkit=3Dgtk3 --with-toolkit-scroll-bars 'CFLAGS=3D-g -O2
 -fdebug-prefix-map=3D/build/emacs-StqULU/emacs-26.1+1=3D. -fstack-
protector-strong
 -Wformat -Werror=3Dformat-security -Wall' 'CPPFLAGS=3D-Wdate-time
 -D_FORTIFY_SOURCE=3D2' LDFLAGS=3D-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LANG: hu_HU.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

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.

=46eatures:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils pp cl-print
byte-opt gv bytecomp byte-compile cconv thingatpt help-fns radix-tree
help-mode easymenu cl-loaddefs cl-lib elec-pair time-date mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame 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 minibuffer 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 dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 102224 12976)
 (symbols 48 20553 1)
 (miscs 40 55 104)
 (strings 32 30980 919)
 (string-bytes 1 777673)
 (vectors 16 15007)
 (vector-slots 8 501086 9156)
 (floats 8 56 171)
 (intervals 56 290 0)
 (buffers 992 12))







Acknowledgement sent to Braun Gábor <braungb88@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#38316; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.