all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Fussner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: 53749@debbugs.gnu.org, Ikumi Keita <ikumi@ikumi.que.jp>,
	Dmitry Gutov <dmitry@gutov.dev>, Arash Esbati <arash@gnu.org>,
	Stefan Kangas <stefankangas@gmail.com>,
	Tassilo Horn <tsdh@gnu.org>, Eli Zaretskii <eliz@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#53749: 29.0.50; [PATCH] Xref backend for TeX buffers
Date: Mon, 16 Sep 2024 14:30:20 +0100	[thread overview]
Message-ID: <CADF+Rtga3bzzJDDComrvs3EFgSSX3tW7jCXPOTmVqo-k5_ukgA@mail.gmail.com> (raw)
In-Reply-To: <CADF+RtgRO-Au2DzQ8JhQf9tcGR9OAU0BjP_h2Rjc15PBHtWPGw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3263 bytes --]

Hi Mattias, Arash,

Here's a patch to fix the regexps and delete the unnecessary variable.
Any thoughts?

I'll look at adding new vars for the TeX escape and grouping chars,
creating a new bug number when I have a working patch.

Thanks, David.

On Mon, 16 Sept 2024 at 09:33, David Fussner <dfussner@googlemail.com> wrote:
>
> Hi Mattias,
>
> Thanks for this, and of course you are quite right on both counts:
>
> > but it also depends on what you want that `tex-thingatpt-exclude-chars` variable to be
>
> I believe it's time I abandoned this piece of idiocy, already flagged
> by several commentators before you. The basic motivation was to allow
> using the new xref code in TeX files that used non-standard escape and
> grouping characters. Both etags and AUCTeX address this possibility,
> but the latter does it right by having three separate variables:
> TeX-esc, TeX-grop, and TeX-grcl, so that these can be part of the
> whole regular expression apparatus for syntax highlighting and
> everything else. I had in the back of my mind to implement something
> similar in tex-mode, but the half-measure of
> `tex-thingatpt-exclude-chars` is the wrong way to go.
>
> I propose, therefore, to eliminate this variable from tex-mode and
> just hard code the standard escape and grouping characters for the
> time being, as in the rest of tex-mode.el, then to submit later a
> patch to implement something similar to what AUCTeX does, and one
> interoperable with AUCTeX, also.
>
> > This is not a correct way to build a regexp;
>
> Given the above changes, would you and your electronic servant be OK
> with code like the following?
>
> (re-search-forward "[][\\{}\"*`'#=&()%,|$[:cntrl:][:blank:]]")
>
> (I still, I'm ashamed to confess, find the traditional regexp syntax
> easier to read than rx notation, but could overcome this if you think
> rx is a better fit here.)
>
> What do you think?
>
> Best,  David.
>
> On Sat, 14 Sept 2024 at 18:26, Mattias Engdegård
> <mattias.engdegard@gmail.com> wrote:
> >
> > Thanks for the contribution, David! My electronic servant complained about some regexps:
> >
> > 3881    (re-search-backward (concat "[]["
> > 3882                                (mapconcat #'regexp-quote
> > 3883                                           (mapcar #'char-to-string
> > 3884                                                   tex-thingatpt-exclude-chars))
> > 3885                                "\"*`'#=&()%,|$[:cntrl:][:blank:]]"))
> >
> > This is not a correct way to build a regexp; `regexp-quote` can only be used to quote strings that should match literally, not characters inside [...], where backslashes have no escaping power.
> >
> > There are various ways of doing this properly. I would suggest something like
> >
> >   (rx-to-string `(or (in "\"#$%&'()*,=[]`|" cntrl blank)
> >                      ,@tex-thingatpt-exclude-chars)
> >                 t))
> >
> > but it also depends on what you want that `tex-thingatpt-exclude-chars` variable to be. Should it be a user option (defcustom)? The variable's doc string is a wall of text that basically says that it can be set to whatever you want but things will stop working so you'd better not.
> >

[-- Attachment #2: 0001-Fix-regexps-for-TeX-xref-backend-Bug-53749.patch --]
[-- Type: text/x-patch, Size: 3821 bytes --]

From 1c607543556a7b79615dbc5e8384e10d92d081d5 Mon Sep 17 00:00:00 2001
From: David Fussner <dfussner@googlemail.com>
Date: Mon, 16 Sep 2024 14:05:01 +0100
Subject: [PATCH] Fix regexps for TeX xref backend (Bug#53749)

* lisp/textmodes/tex-mode.el (tex-thingatpt-exclude-chars): Remove
var.
(tex-thingatpt--beginning-of-symbol, tex-thingatpt--end-of-symbol):
Use hard-coded chars instead of var.
---
 lisp/textmodes/tex-mode.el | 43 ++------------------------------------
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index ec0c0c47a2d..6fc49800018 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -3814,37 +3814,6 @@ tex-chktex
 ;; Emacs and `etags' this way aims to improve the user experience "out
 ;; of the box."
 
-(defvar tex-thingatpt-exclude-chars '(?\\ ?\{ ?\})
-  "Exclude these chars by default from TeX thing-at-point.
-
-The TeX `xref-backend-identifier-at-point' method uses the characters
-listed in this variable to decide on the default search string to
-present to the user who calls an `xref' command.  These characters
-become part of a regexp which always excludes them from that default
-string.  For the `xref' commands to function properly in TeX buffers, at
-least the TeX escape and the two TeX grouping characters should be
-listed here.  Should your TeX documents contain other characters which
-you want to exclude by default, then you can add them to the list,
-though you may wish to consult the functions
-`tex-thingatpt--beginning-of-symbol' and `tex-thingatpt--end-of-symbol'
-to see what the regexp already contains.  If your documents contain
-non-standard escape and grouping characters, then you can replace the
-three listed here with your own, thereby allowing the three standard
-characters to appear by default in search strings.  Please be aware,
-however, that the `etags' program only recognizes `\\' (92) and `!' (33)
-as escape characters in TeX documents, and if it detects the latter it
-also uses `<>' as the TeX grouping construct rather than `{}'.  Setting
-the escape and grouping chars to anything other than `\\=\\{}' or `!<>'
-will not be useful without changes to `etags', at least for commands
-that search tags tables, such as \\[xref-find-definitions] and \
-\\[xref-find-apropos].
-
-Should you wish to change the defaults, please also be aware that,
-without further modifications to tex-mode.el, the usual text-parsing
-routines for `font-lock' and the like won't work correctly, as the
-default escape and grouping characters are currently hard coded in many
-places.")
-
 ;; Populate `semantic-symref-filepattern-alist' for the in-tree modes;
 ;; AUCTeX is doing the same for its modes.
 (with-eval-after-load 'semantic/symref/grep
@@ -3878,20 +3847,12 @@ tex--thing-at-point
 
 (defun tex-thingatpt--beginning-of-symbol ()
   (and
-   (re-search-backward (concat "[]["
-                               (mapconcat #'regexp-quote
-                                          (mapcar #'char-to-string
-                                                  tex-thingatpt-exclude-chars))
-                               "\"*`'#=&()%,|$[:cntrl:][:blank:]]"))
+   (re-search-backward "[][\\{}\"*`'#=&()%,|$[:cntrl:][:blank:]]" nil t)
    (forward-char)))
 
 (defun tex-thingatpt--end-of-symbol ()
   (and
-   (re-search-forward (concat "[]["
-                              (mapconcat #'regexp-quote
-                                          (mapcar #'char-to-string
-                                                  tex-thingatpt-exclude-chars))
-                              "\"*`'#=&()%,|$[:cntrl:][:blank:]]"))
+   (re-search-forward "[][\\{}\"*`'#=&()%,|$[:cntrl:][:blank:]]" nil t)
    (backward-char)))
 
 (defun tex--bounds-of-symbol-at-point ()
-- 
2.39.4


  reply	other threads:[~2024-09-16 13:30 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 15:09 bug#53749: 29.0.50; [PATCH] Xref backend for TeX buffers David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21  2:11 ` Dmitry Gutov
2022-02-21  9:48   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 17:28     ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 23:56       ` Dmitry Gutov
2022-02-22 15:19         ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23  2:21           ` Dmitry Gutov
2022-02-23 10:45             ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-24  2:23               ` Dmitry Gutov
2022-02-24 13:15                 ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 23:55     ` Dmitry Gutov
2022-09-08 13:25   ` Lars Ingebrigtsen
2022-09-08 13:34     ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-08 13:39       ` Lars Ingebrigtsen
2022-09-08 15:50         ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03  9:08           ` Stefan Kangas
2023-09-03 10:03             ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 10:46               ` Stefan Kangas
2023-09-13 11:10                 ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-13 13:42                   ` Stefan Kangas
2023-09-13 15:23                   ` Dmitry Gutov
2023-09-13 17:01                     ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-13 23:59                       ` Dmitry Gutov
2023-09-14  6:10                         ` Eli Zaretskii
2023-09-15 18:45                           ` Tassilo Horn
2023-09-16  5:53                             ` Ikumi Keita
2023-09-17  8:49                               ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 13:06                                 ` Arash Esbati
2024-04-22 14:56                                   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 16:15                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 16:37                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 17:16                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 17:25                                           ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-24  0:09                                           ` Dmitry Gutov
2024-04-24  9:02                                             ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-23 12:04                                     ` Arash Esbati
2024-04-23 13:21                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 14:15                                   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-02  0:43                                     ` Dmitry Gutov
2024-05-02 13:32                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-03 13:42                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-07  2:27                                           ` Dmitry Gutov
2024-05-09  3:00                                             ` Dmitry Gutov
2024-05-09  6:38                                               ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-09 10:49                                               ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-13 20:54                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 21:24                                                 ` Dmitry Gutov
2024-05-16 18:18                                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-20  0:21                                                     ` Dmitry Gutov
2024-05-20  2:38                                                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-25  7:57                                                         ` Eli Zaretskii
2024-06-05  9:46                                                           ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 12:38                                                             ` Eli Zaretskii
2024-06-08 20:54                                                               ` Dmitry Gutov
2024-06-09 11:10                                                             ` Stefan Kangas
2024-06-09 11:36                                                             ` Stefan Kangas
2024-06-09 18:42                                                               ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-09 18:45                                                               ` Dmitry Gutov
2024-06-09 21:03                                                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-09 22:13                                                                   ` Dmitry Gutov
2024-06-10 13:29                                                                     ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-27 15:39                                                                       ` Arash Esbati
2024-07-28 23:57                                                                         ` Dmitry Gutov
2024-07-29 10:31                                                                           ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-14 13:43                                                                           ` Stefan Kangas
2024-09-14 14:06                                                                             ` Eli Zaretskii
2024-09-14 15:02                                                                               ` Dmitry Gutov
2024-09-14 15:08                                                                               ` Stefan Kangas
2024-09-14 15:28                                                                                 ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-25 23:01                                                         ` Dmitry Gutov
2024-05-07  2:06                                         ` Dmitry Gutov
2024-05-02  6:47                                     ` Arash Esbati
2024-05-02 13:34                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-03 14:10                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-04  8:26                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-04 14:32                                       ` Arash Esbati
2024-05-04 14:54                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-04 21:15                                           ` Arash Esbati
2024-05-07 13:15                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-15 15:47                                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-16  7:53                                         ` Arash Esbati
2024-05-16 12:56                                           ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14 16:11                         ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14 23:55                           ` Dmitry Gutov
2023-09-15  6:47                             ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-13 19:16                     ` Eli Zaretskii
2023-09-13 20:25                       ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14  5:14                         ` Eli Zaretskii
2022-02-21 12:35 ` Arash Esbati
2022-02-21 14:03   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 20:16 ` Augusto Stoffel
2022-02-26  9:29   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 10:56     ` Augusto Stoffel
2022-02-27 18:42       ` Arash Esbati
2022-02-28  9:09         ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-28 11:54           ` Arash Esbati
2022-02-28 13:11             ` Augusto Stoffel
2022-02-28 19:04               ` Arash Esbati
2022-03-01  8:46                 ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-28 13:05           ` Augusto Stoffel
2024-09-14 17:26 ` Mattias Engdegård
2024-09-16  8:33   ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-16 13:30     ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-09-21  2:07       ` Stefan Kangas
2024-09-21 16:44         ` David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-17 12:35     ` Mattias Engdegård

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=CADF+Rtga3bzzJDDComrvs3EFgSSX3tW7jCXPOTmVqo-k5_ukgA@mail.gmail.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53749@debbugs.gnu.org \
    --cc=arash@gnu.org \
    --cc=dfussner@googlemail.com \
    --cc=dmitry@gutov.dev \
    --cc=eliz@gnu.org \
    --cc=ikumi@ikumi.que.jp \
    --cc=mattias.engdegard@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    --cc=tsdh@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.