auctex-devel
[Top][All Lists]
Advanced

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

`LaTeX-verbatim-p' moves point


From: Arash Esbati
Subject: `LaTeX-verbatim-p' moves point
Date: Thu, 02 Nov 2023 20:28:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi all,

`LaTeX-verbatim-p' is defined as:

--8<---------------cut here---------------start------------->8---
(defun LaTeX-verbatim-p (&optional pos)
  "Return non-nil if position POS is in a verbatim-like construct.
The macro body (\"\\verb\") and its delimiters, including
optional argument if any, aren't considered as component of a
verbatim-like construct."
  (when pos (goto-char pos))
  (save-match-data
    ;; TODO: Factor out syntax propertize facility from font-latex.el
    ;; and re-implement as major mode feature.  Then we can drop the
    ;; fallback code below.
    (if (eq TeX-install-font-lock 'font-latex-setup)
        (progn
          (syntax-propertize (point))
          (nth 3 (syntax-ppss)))
      ;; Fallback for users who stay away from font-latex.
      (or
       (let ((region (LaTeX-verbatim-macro-boundaries t)))
         (and region
              (<= (car region) (point) (cdr region))))
       (member (LaTeX-current-environment) (LaTeX-verbatim-environments))))))
--8<---------------cut here---------------end--------------->8---

As you can see, the body isn't guarded with (save-excursion ...) so if
the optional argument POS is given, point is moved permanently.  Is this
on purpose?  I tend to forget this when I use the function (or
`TeX-verbatim-p') and wonder why point is moved for some minutes.  Is it
safe to change this behavior?

Any comments welcome.

Best, Arash



reply via email to

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