unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point
@ 2022-09-23 15:14 Richard Hopkins
  2022-09-24 12:14 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Hopkins @ 2022-09-23 15:14 UTC (permalink / raw)
  To: 58029

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point
  2022-09-23 15:14 bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point Richard Hopkins
@ 2022-09-24 12:14 ` Lars Ingebrigtsen
  2022-09-24 13:33   ` Richard Hopkins
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-24 12:14 UTC (permalink / raw)
  To: Richard Hopkins; +Cc: 58029

Richard Hopkins <emacs@unbit.co.uk> writes:

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

I can reproduce this in Emacs 28.2, but not in Emacs 29, so it looks
like this has been fixed already.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point
  2022-09-24 12:14 ` Lars Ingebrigtsen
@ 2022-09-24 13:33   ` Richard Hopkins
  2022-09-24 13:42     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Hopkins @ 2022-09-24 13:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 58029

On 2022-09-24 13:14, Lars Ingebrigtsen wrote:
> I can reproduce this in Emacs 28.2, but not in Emacs 29, so it looks
> like this has been fixed already.

Thanks for checking, however, I still get the same issue on what I
believe is Emacs 29...

$ src/emacs --version
GNU Emacs 29.0.50
Development version 1556b4376457 on master branch; build date 
2022-09-24.

As this also affects `backward-sexp' etc I was looking into a general
patch, but as it works for you I wonder if I'm running the wrong
version?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point
  2022-09-24 13:33   ` Richard Hopkins
@ 2022-09-24 13:42     ` Lars Ingebrigtsen
  2022-09-24 14:02       ` Richard Hopkins
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-24 13:42 UTC (permalink / raw)
  To: Richard Hopkins; +Cc: 58029

Richard Hopkins <emacs@unbit.co.uk> writes:

> Thanks for checking, however, I still get the same issue on what I
> believe is Emacs 29...

It only recognises these constructs if you're in a buffer where the
syntax rules say so.  So try:

(with-temp-buffer
  (insert (prin1-to-string (make-foo :a 1)))
  (emacs-lisp-mode)
  (goto-char (point-min))
  (list
   (buffer-string)
   (bounds-of-thing-at-point 'sexp)
   (prin1-to-string (read (current-buffer)))))

=> ("#s(foo 1)" (1 . 10) "#s(foo 1)")





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point
  2022-09-24 13:42     ` Lars Ingebrigtsen
@ 2022-09-24 14:02       ` Richard Hopkins
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Hopkins @ 2022-09-24 14:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 58029

On 2022-09-24 14:42, Lars Ingebrigtsen wrote:
> It only recognises these constructs if you're in a buffer where the
> syntax rules say so.  So try:
> 
> (with-temp-buffer
>   (insert (prin1-to-string (make-foo :a 1)))
>   (emacs-lisp-mode)
>   (goto-char (point-min))
>   (list
>    (buffer-string)
>    (bounds-of-thing-at-point 'sexp)
>    (prin1-to-string (read (current-buffer)))))
> 
> => ("#s(foo 1)" (1 . 10) "#s(foo 1)")

Ah, thanks for the pointer.  It works for me too (and `backward-sexp')
starting from Emacs 29 when the relevant mode is set, including the
scratch buffer with `lisp-interaction-mode'.

Please close, thanks.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-24 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 15:14 bug#58029: 28.2; Struct boundaries ignored by bounds-of-thing-at-point Richard Hopkins
2022-09-24 12:14 ` Lars Ingebrigtsen
2022-09-24 13:33   ` Richard Hopkins
2022-09-24 13:42     ` Lars Ingebrigtsen
2022-09-24 14:02       ` Richard Hopkins

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).