[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#73938: [PATCH] Add folding support for TeX quotes
From: |
Ikumi Keita |
Subject: |
bug#73938: [PATCH] Add folding support for TeX quotes |
Date: |
Wed, 30 Oct 2024 00:48:54 +0900 |
>>>>> Paul Nelson <ultrono@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