all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Guillaume Brunerie <guillaume.brunerie@gmail.com>
To: 74415@debbugs.gnu.org
Subject: bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties
Date: Mon, 18 Nov 2024 11:12:49 +0100	[thread overview]
Message-ID: <CAFJ3QW+BzqN8MhGOra=EtCyFQryH0zqNu3pC5D5pLM6z1kLfLw@mail.gmail.com> (raw)

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





             reply	other threads:[~2024-11-18 10:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18 10:12 Guillaume Brunerie [this message]
2024-11-24  9:59 ` bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFJ3QW+BzqN8MhGOra=EtCyFQryH0zqNu3pC5D5pLM6z1kLfLw@mail.gmail.com' \
    --to=guillaume.brunerie@gmail.com \
    --cc=74415@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.