GNU bug report logs - #73938
[PATCH] Add folding support for TeX quotes

Previous Next

Package: auctex;

Reported by: Paul Nelson <ultrono <at> gmail.com>

Date: Mon, 21 Oct 2024 20:45:02 UTC

Severity: normal

Tags: patch

Fixed in version 14.0.8

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 73938 <at> debbugs.gnu.org
Subject: bug#73938: [PATCH] Add folding support for TeX quotes
Date: Wed, 30 Oct 2024 00:48:54 +0900
>>>>> Paul Nelson <ultrono <at> gmail.com> writes:
> Thanks Ikumi, I've adjusted accordingly (I'll send the final patch
> pre-merge, assuming that there will be other comments in the mean
> time)

I think it is basically OK. Please send us your latest patch. Some of
nitpicking matters:

1.
----------------------------------------------------------------------
(defun TeX-fold-quotes (start end)
  "Fold LaTeX quotes between START and END.
Replaces opening and closing quotes with `TeX-fold-open-quote' and
`TeX-fold-close-quote', respectively, except in math environments,
verbatim contexts and comments."
  (pcase-let ((`(,open-quote ,close-quote _) (TeX-get-quote-characters)))
    (save-excursion
      (goto-char start)
      (while (re-search-forward (regexp-opt (list open-quote close-quote)) end t)
----------------------------------------------------------------------
In the course of this `while' loop, the regexp is always regenerated by
`regexp-opt'. However, it is actually constant during the loop. Thus I'd
prefer something like
(let ((regexp (regexp-opt ...)))
  (while (re-search-forward regexp ...)


2.
----------------------------------------------------------------------
(defun TeX-fold-quotes (start end)
[...]
        (let ((str (if (string= (match-string 0) open-quote)
----------------------------------------------------------------------
If I understand correctly, `match-string-no-properties' would be enough
here.

3.
----------------------------------------------------------------------
(defun TeX-insert-quote (force)
[...]
        (save-excursion
          (let* ((end (point))
                 (start (- end
                           (length
                            (if (string-match-p (regexp-quote open-quote)
                                                (buffer-substring-no-properties (- end (length open-quote)) end))
----------------------------------------------------------------------
We can just use `string=' instead of regexp+regexp-quote here.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




This bug report was last modified 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.