unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties
@ 2024-11-18 10:12 Guillaume Brunerie
  2024-11-24  9:59 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Guillaume Brunerie @ 2024-11-18 10:12 UTC (permalink / raw)
  To: 74415

Hello,

The `mouse-start-end` function (used in particular when double clicking on an
opening parenthesis to select the region from that opening parenthesis to the
matching closing parenthesis) does not respect syntax-table text properties to
determine if the character at point is an opening parenthesis. Looking at the
code, it is at line 1941 in lisp/mouse.el (and there are more instances further
down in the same file)
(https://github.com/emacs-mirror/emacs/blob/eee0ed8442aa78320a3e578ab290df145fb49624/lisp/mouse.el#L1941):

    ((and (= mode 1)
          (= start end)
          (char-after start)
          (= (char-syntax (char-after start)) ?\())

Note that the documentation of `char-syntax` says:

> If you’re trying to determine the syntax of characters in the buffer, this is
> probably the wrong function to use, because it can’t take ‘syntax-table’ text
> properties into account. Consider using ‘syntax-after’ instead.

The line just below does use `syntax-after`, but it looks like something that
was added later to work around a related bug. I think this function should be
refactored to only use `syntax-after` instead of `char-syntax`.

For context, I'm writing my own Typescript major mode where the < and > symbols
are sometimes balanced delimiters, sometimes not (determined via Tree-sitter). I
could get most things working using syntax-table text properties, like
forward-sexp and show-paren-mode, but not double-click selection due to this
issue.

Related: https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-02/msg00988.html
In that issue, the opposite problem occurred, double clicking on an unmatched
open parenthesis did not take into account the "punctuation" text property. But
the fix only fixed one half of the issue (when a text property makes a
parenthesis into not a parenthesis) and I am facing the other half (a text
property makes a punctuation character into a parenthesis).

Best,
Guillaume





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

end of thread, other threads:[~2024-12-13 17:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 10:12 bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties Guillaume Brunerie
2024-11-24  9:59 ` Eli Zaretskii
2024-11-25 23:15   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-28 16:02     ` Eli Zaretskii
2024-11-28 20:03       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05  6:13       ` Guillaume Brunerie
2024-12-07 12:33         ` Eli Zaretskii
2024-12-09 19:21           ` Guillaume Brunerie
2024-12-13 17:05             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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