bug-auctex
[Top][All Lists]
Advanced

[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: Arash Esbati
Subject: bug#56160: 13.1.3; fill breaks verbatim macros not followed with spaces
Date: Fri, 01 Jul 2022 18:33:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Arash Esbati <arash@gnu.org> writes:

> 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':

--8<---------------cut here---------------start------------->8---
(defun LaTeX-verbatim-p (&optional pos)
  "Return non-nil if position POS is in a verbatim-like construct."
  (when pos (goto-char pos))
  (save-match-data
    (or (when (and (fboundp 'font-latex-faces-present-p)
                   (bound-and-true-p font-lock-mode))
          (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)))
        (member (LaTeX-current-verbatim-macro)
                (LaTeX-verbatim-macros-with-delims))
        (member (TeX-current-macro) (LaTeX-verbatim-macros-with-braces))
        (member (LaTeX-current-environment) (LaTeX-verbatim-environments))
        (when LaTeX-shortvrb-chars
          (let* ((strings (mapcar #'string LaTeX-shortvrb-chars))
                 (regexp (concat "[^\\]"
                                 (mapconcat #'regexp-quote strings "\\|")))
                 (p (point))
                 (match (save-excursion
                          (re-search-forward regexp (line-end-position) t))))
            (and match
                 (save-excursion
                   (cl-oddp (how-many regexp (line-beginning-position) p)))
                 (save-excursion
                   (cl-evenp (how-many regexp (line-beginning-position) 
match)))))))))
--8<---------------cut here---------------end--------------->8---

Any comments welcome.

Best, Arash





reply via email to

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