Subject: bug#52896: 29.0.50; transient-mark-mode is set to a lot of 'only syms

From: Andrey Listopadov <[email-masked]>
Date: Thu, 30 Dec 2021 12:53:08 +0300

I've installed the expand-region.el package and noticed that transient
mark mode started misbehaving.  I'm using Emacs with
`transient-mark-mode' disabled, and enable it occasionally via `C-SPC
C-SPC' when needed.  After using `er/expand-region' function I've
noticed that `C-SPC C-SPC' doesn't highlight the region.  Upon further
inspection I've noticed that the `transient-mark-mode' variable is set
to `(only only only only only ... only) with a total of 26 `only'
symbols.  Symbols disappear one by one when I move the point or invoke
other commands, so eventually `C-SPC C-SPC' starts working again.

I've added a watcher to the `transient-mark-mode' variable and upon
first activation of expand region I see this:

    transient-mark-mode (only) set #<buffer *scratch*>
    transient-mark-mode (only only) set #<buffer *scratch*>
    transient-mark-mode (only only only) set #<buffer *scratch*>
    transient-mark-mode (only only only only) set #<buffer *scratch*>
    Type = to expand again, - to contract, 0 to reset

Upon further investigation I've found that this happens inside the
`exchange-point-and-mark' function.  I've added a message right before
`cons' call to confirm that:

    transient-mark-mode (only) set #<buffer *scratch*>
    exchange-point-and-mark
    transient-mark-mode (only only) set #<buffer *scratch*>
    exchange-point-and-mark
    transient-mark-mode (only only only) set #<buffer *scratch*>
    exchange-point-and-mark
    transient-mark-mode (only only only only) set #<buffer *scratch*>
    Type = to expand again, - to contract, 0 to reset

The function explicitly checks if ``(eq (car-safe transient-mark-mode)
'only)'' is true and then conses `only' to the `transient-mark-mode',
causing it to grow.  I'm not sure what is the intention here, but this
makes it harder using `C-SPC C-SPC` to temporarily activate the
transient mark mode.

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.17.4)
 of 2021-12-29 built on toolbox
Repository revision: 3fc8032a1aac535e8f6ba03547bd9fa2b0880193
Repository branch: master
System Description: Fedora Linux 35 (Workstation Edition)

Configured using:
 'configure --with-native-compilation --with-pgtk
 --prefix=/home/alist/.local'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-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
  indent-tabs-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail comp comp-cstr cl-extra
help-mode pcase org-macs cap-words superword subword ruby-mode smie rx
python tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat shell pcomplete parse-time iso8601 ls-lisp format-spec
rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt
rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util
nxml-enc xmltok html-mode-expansions sgml-mode facemenu dom cc-cmds
cc-engine cc-vars cc-defs er-basic-expansions thingatpt
expand-region-core advice expand-region-custom warnings cl compile
comint ansi-color ring autoload radix-tree lisp-mnt tar-mode arc-mode
archive-mode mm-archive message yank-media dired dired-loaddefs rfc822
mml mml-sec epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mailabbrev gmm-utils mailheader mm-decode
mm-bodies mm-encode mail-utils gnutls network-stream url-http mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc
puny url-cache url-auth cus-edit pp cus-start cus-load wid-edit
finder-inf package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt
bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/pgtk-win pgtk-win term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax 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 emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit pgtk lcms2 multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 193794 12810)
 (symbols 48 17181 1)
 (strings 32 60612 2225)
 (string-bytes 1 2133315)
 (vectors 16 30994)
 (vector-slots 8 449511 20505)
 (floats 8 76 163)
 (intervals 56 595 0)
 (buffers 992 15))