[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#56160: 13.1.3; fill breaks verbatim macros not followed with spaces

From: Ikumi Keita
Subject: bug#56160: 13.1.3; fill breaks verbatim macros not followed with spaces
Date: Sat, 02 Jul 2022 17:52:39 +0900

>>>>> Arash Esbati <arash@gnu.org> writes:
> That was also my first approach, but then I thought I make it more
> robust since we really don't know what people will choose as delimiters.


> Actually, I think we have change that to:

>     (regexp (concat "[^\\]" (mapconcat #'regexp-quote strings "\\|")))

> to exclude things like \|, \- and \" etc.

(1) Alternatives concatenated by mapconcat must be enclosed with \(?:...\),
    otherwise "[^\\]" affects only the first component.
(2) This regexp doesn't match a shortvrb delimiter at the BOL
    because the regexp search is limited at (line-beginning-position).

Considering the above two points, the regexp should be built as
    (regexp (concat "\\(?:[^\\]\\|^\\)\\(?:"
               (mapconcat #'regexp-quote strings "\\|") "\\)"))

> Please consider this example, and hit 'M-q' in the paragraphs once with
> `font-lock-mode' enabled and once disabled:

> I think the issue is that '|' has also `font-latex-verbatim-face' which
> makes Emacs travel to far back when searching for the next break point.


> I'm not sure what's the best approach to fix this, what do you think?

> Following up myself, I think I have an idea which excludes the boundries
> while looking for `font-latex-verbatim-face':
(defun LaTeX-verbatim-p (&optional pos)
          (if (and LaTeX-shortvrb-chars
                   (member (following-char) LaTeX-shortvrb-chars))
              (let ((regexp (concat "[^" TeX-esc "]"
                                    (regexp-quote (string (following-char))))))
                (if (cl-oddp (how-many regexp (line-beginning-position) (1+ 
                    (font-latex-faces-present-p 'font-latex-verbatim-face (1- 
                  (font-latex-faces-present-p 'font-latex-verbatim-face (1+ 
            (font-latex-faces-present-p 'font-latex-verbatim-face)))
Hmm, rather complex. In addition, this code returns nil just before the
closing shortvrb delimiter. How about this?
          (if (and LaTeX-shortvrb-chars
                   (memq (following-char) LaTeX-shortvrb-chars))
              (and (font-latex-faces-present-p 'font-latex-verbatim-face)
                   (font-latex-faces-present-p 'font-latex-verbatim-face
                                               (1- (point))))
            (font-latex-faces-present-p 'font-latex-verbatim-face)))

Ikumi Keita
#StandWithUkraine #StopWarInUkraine

reply via email to

[Prev in Thread] Current Thread [Next in Thread]