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

Previous Next

Package: emacs;

Reported by: Braun Gábor <braungb88 <at> gmail.com>

Date: Thu, 21 Nov 2019 21:19:04 UTC

Severity: normal

Found in version 26.1

To reply to this bug, email your comments to 38316 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38316; Package emacs. (Thu, 21 Nov 2019 21:19:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Braun Gábor <braungb88 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 21 Nov 2019 21:19:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Braun Gábor <braungb88 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1;
 Undo with undo-inhibit-record-point set doesn't restore unmodified
 state
Date: Thu, 21 Nov 2019 22:18:21 +0100
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 
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.  
*/
  if (undo_inhibit_record_point)
    return;
    
  ...
  
  /* If this is the first change since save, then record this.*/
  if (MODIFF <= SAVE_MODIFF)
    record_first_change ();

  /* We may need to record point ...*/
  if (at_boundary
      && point_before_last_command_or_undo != beg
      && buffer_before_last_command_or_undo == 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ábor


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 
11.0.12004000
System Description:	Debian GNU/Linux 10 (buster)

Recent messages:
For 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=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/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=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/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=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-StqULU/emacs-26.1+1=. -fstack-
protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-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.

Features:
(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))







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38316; Package emacs. (Sun, 01 Nov 2020 14:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 38316 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Braun Gábor <braungb88 <at> gmail.com>
Cc: 38316 <at> debbugs.gnu.org
Subject: Re: bug#38316: 26.1; Undo with undo-inhibit-record-point set
 doesn't restore unmodified state
Date: Sun, 01 Nov 2020 15:50:36 +0100
Braun Gábor <braungb88 <at> gmail.com> writes:

> 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 
> 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.

I can confirm that this bug is still present in Emacs 28.

> 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.

Yup.  (The bug report then goes on to discuss the differences in
buffer-undo-list, which is probably the cause of this bug.)

Does anybody have any insight here into what's going wrong here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 228 days ago.

Previous Next


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