GNU bug report logs - #61400
Different filling for verbatim macros

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Fri, 10 Feb 2023 08:53:01 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #50 received at 61400 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Arash Esbati <arash <at> gnu.org>
Cc: 61400 <at> debbugs.gnu.org, Tassilo Horn <tsdh <at> gnu.org>
Subject: Re: bug#61400: Different filling for verbatim macros
Date: Tue, 14 Feb 2023 15:46:53 +0900
[Message part 1 (text/plain, inline)]
Hi Arash,

>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Do we really want this?  My gut feeling is to have `LaTeX-verbatim-p'
> returns t just before the "\verb|...|" etc., i.e., when cursor is over
> the backslash.

OK, then another candidate is the attached patch. This keeps the current
behavior of `LaTeX-verbatim-p' and introduces a new function
`LaTeX-verbatim-nobreak-p' as you suggested in your previous message.

However, I'm a bit reluctant.
1. If `LaTeX-verbatim-p' should return non-nil at just before
   "\verb", then it should also do so just before "\begin{verbatim}" for
   consistency, shouldn't it?
2. Suppose that you type "$" just before "\verb...". Then
   `TeX-insert-dollar' inserts only one "$" instead of "$$" under the
   current behavior of `LaTeX-verbatim-p', because `TeX-insert-dollar'
   uses `TeX-verbatim-p'. I think it's unexpected. 

> Thanks, LGTM.  One other complication we have to deal with is that \Verb
> from fancyvrb or \lstinline from listings can have an optional argument,
> e.g.:

>   \Verb[fontsize=\scriptsize]|foo bar|

Thanks, I incorporated it with slight modification in the attached patch.

>> +;; (defun LaTeX-current-verbatim-macro ()
>> +;;   "Return name of verbatim macro containing point, nil if none is present."
>> +;;   (let ((macro-boundaries (LaTeX-verbatim-macro-boundaries)))
>> +;;     (when macro-boundaries
>> +;;       (save-excursion
>> +;;         (goto-char (car macro-boundaries))
>> +;;         (forward-char (length TeX-esc))
>> +;;         (buffer-substring-no-properties
>> +;;          (point) (progn (skip-chars-forward "@A-Za-z*") (point)))))))

> Would it make sense to keep the above as a utility function?

This time I leave that function as is.

> And while we're at it: The docstring isn't correct any more, right?  I
> mean this part:

>     It doesn't regard the point just before \\verb... etc. belongs to
>     the verbatim macro.  This isn't symmetric with
>     `TeX-find-macro-boundaries'.

In my previous patch, it's correct because I removed the chunk
      (if (looking-at (concat (regexp-quote TeX-esc) verbatim-regexp))
          (forward-char 1)
from `LaTeX-verbatim-macro-boundaries'. :-)

(By the way, I noticed that `LaTeX-verbatim-p' raises error when "\verb"
is at the end of the buffer without delimiters and its contents "|...|".
In fact `LaTeX-verbatim-macro-boundaries' and
`LaTeX-current-verbatim-macro' raise the same error. The reason is that
`LaTeX-verbatim-macro-boundaries' presumes there is nonempty string
after the macro body. Should we cater for such corner case?)

Best,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

[patch (text/x-diff, attachment)]

This bug report was last modified 2 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.