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

Hi Keita,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

>>>>>> Arash Esbati <arash@gnu.org> writes:
>> Maybe we should add this
>> (add-to-list (make-local-variable 'fill-nobreak-predicate)
>>              #'LaTeX-verbatim-p t)
>> to `LaTeX-common-initialization'?
> Thanks, that makes more sense. Common rule should apply for auto fill as
> well.

I'm not sure I understand the last sentence.  Can you elaborate?

> Then the fix should look like the attached patch.

LGTM.  Please go ahead and install it.

> +  ;; Cater for \verb|...| (and similar) contructs which should not be
> +  ;; broken. (FIXME: Make it work with shortvrb.sty (also loaded by
> +  ;; doc.sty) where |...| is allowed.  Arbitrary delimiters may be
> +  ;; chosen with \MakeShortVerb{<char>}.)
> +  (add-to-list (make-local-variable 'fill-nobreak-predicate)
> +               #'LaTeX-verbatim-p t)

I think we can also adjust `LaTeX-verbatim-p' to handle the FIXME.
AUCTeX doesn't parse files for \MakeShortVerb, it looks at the chars
defined in `LaTeX-shortvrb-chars' for delimiters.  We could do something
like this in `LaTeX-verbatim-p' (addition starts with (when
LaTeX-shortvrb-chars ...):

--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))
    (or (when (fboundp 'font-latex-faces-present-p)
          (font-latex-faces-present-p 'font-latex-verbatim-face))
        (member (LaTeX-current-verbatim-macro)
        (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 "\\|")
            (and (save-excursion
                   (re-search-backward regexp (line-beginning-position) t))
                   (re-search-forward (regexp-quote (match-string-no-properties 
                                      (line-end-position) t))))))))
--8<---------------cut here---------------end--------------->8---

This is also a small test file if you like to play with it:

--8<---------------cut here---------------start------------->8---
|foo| and "bar" 

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% LaTeX-shortvrb-chars: (?|)
%%% End:
--8<---------------cut here---------------end--------------->8---


Best, Arash

reply via email to

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