[Top][All Lists]

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

bug#61400: Different filling for verbatim macros

From: Ikumi Keita
Subject: bug#61400: Different filling for verbatim macros
Date: Tue, 14 Feb 2023 15:46:53 +0900

Hi Arash,

>>>>> Arash Esbati <arash@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?)

Ikumi Keita
#StandWithUkraine #StopWarInUkraine

Attachment: patch
Description: keep current LaTeX-verbatim-p

reply via email to

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