Subject: 28.2; Struct boundaries ignored by bounds-of-thing-at-point

From: Richard Hopkins <[email-masked]>
Date: Fri, 23 Sep 2022 16:14:31 +0100

I think this is a bug - any thoughts on the following?

The initial "#s" as part of printed structures are ignored by
`bounds-of-thing-at-point' which means it will

a) pick up the wrong expression when inside the printed struct; and
b) ignore the struct even when point is on the initial "#"

The following `emacs -Q` recipe should help show the interaction
between the struct representation and whether it's picked up by
`bounds-of-thing-at-point'.

(require 'cl-lib)
(cl-defstruct foo a)
(make-foo :a 1)
;; => #s(foo 1)

;; Bounds should be found starting from 1, but is nil
(with-temp-buffer
   (insert (prin1-to-string (make-foo :a 1)))
   (goto-char (point-min))
   (list
    (buffer-string)
    (bounds-of-thing-at-point 'sexp)
    (prin1-to-string (read (current-buffer)))))
;; => ("#s(foo 1)" nil "#s(foo 1)")

;; Whilst there is a list from point, the boundary should be
;; adjusted backwards as it's part of a struct.
(with-temp-buffer
   (insert (prin1-to-string (make-foo :a 1)))
   (goto-char (point-min))
   (forward-char 2)
   (list
    (buffer-string)
    (bounds-of-thing-at-point 'sexp)
    (prin1-to-string (read (current-buffer)))))
;; => ("#s(foo 1)" (3 . 10) "(foo 1)")

In GNU Emacs 28.2 (build 1, x86_64-pc-cygwin)
  of 2022-09-15 built on fv-az140-985
Repository revision: 70134aa8264ded36d80248204b2ba43ae3d8f599
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.19044
Configured using:
  'configure
  
--srcdir=/cygdrive/d/a/scallywag/emacs/emacs-28.2-1.x86_64/src/emacs-28.2
  --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=/cygdrive/d/a/scallywag/emacs/emacs-28.2-1.x86_64/build=/usr/src/debug/emacs-28.2-1
  
-fdebug-prefix-map=/cygdrive/d/a/scallywag/emacs/emacs-28.2-1.x86_64/src/emacs-28.2=/usr/src/debug/emacs-28.2-1'
  CPPFLAGS= LDFLAGS='

Configured features:
ACL DBUS GIF GLIB GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES
NOTIFY GFILENOTIFY PDUMPER PNG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XIM XPM ZLIB

Important settings:
   value of $LC_CTYPE: en_GB.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
   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
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search seq byte-opt bytecomp
byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils thingatpt cl-seq cl-macs gv time-date
subr-x cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode 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 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 hashtable-print-readable backquote threads dbusbind
gfilenotify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 53485 7761)
  (symbols 48 6799 1)
  (strings 32 19933 2170)
  (string-bytes 1 623050)
  (vectors 16 13667)
  (vector-slots 8 177937 11466)
  (floats 8 28 287)
  (intervals 56 293 24)
  (buffers 992 11))