>>>>> Arash Esbati <ar...@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.
OK. > 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. Agreed. > 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+ (point)))) (font-latex-faces-present-p 'font-latex-verbatim-face (1- (point))) (font-latex-faces-present-p 'font-latex-verbatim-face (1+ (point))))) (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))) ---------------------------------------------------------------------- Best, Ikumi Keita #StandWithUkraine #StopWarInUkraine _______________________________________________ bug-auctex mailing list bug-auctex@gnu.org https://lists.gnu.org/mailman/listinfo/bug-auctex