bug-auctex
[Top][All Lists]
Advanced

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

Re: [Bug-AUCTeX] 11.86; LaTeX-current-environment related bug


From: Mosè Giordano
Subject: Re: [Bug-AUCTeX] 11.86; LaTeX-current-environment related bug
Date: Mon, 27 May 2013 01:04:12 +0200

2013/5/26 Mosè Giordano <address@hidden>:
> Hi Ralf,
>
> 2013/5/25 Ralf Angeli <address@hidden>:
>> What worked in my case was replacing the second and third occurrences
>> (not the first one) of `TeX-in-commented-line' with `TeX-in-comment'.
> It seems to work also for me and in a ~100 KiB file I don't get the
> "Lisp nesting exceeds `max-lisp-eval-depth'" error I previously
> reported.
This probably won't work in doctex-mode: I get the
"max-lisp-eval-depth" error evaluating `(LaTeX-current-environment)'
at the end of preview.dtx and some other .dtx files.

> How about defining `TeX-in-commented-line' (or a new function) like
> `TeX-in-comment' but without verbatim test?  There should be no
> sensible regression in performance: usually many (most?) "\begin" or
> "\end" macros are placed at the beginning of line, this function would
> immediately return nil in those cases and this is a bit faster than
> the current `TeX-in-commented-line'.
This function should do the work
--8<---------------cut here---------------start------------->8---
(defun TeX-in-comment-p ()
  "Return non-nil if point is in a comment.
Unlike `TeX-in-comment', this function does not check whether the
`%' starting the comment is in a verbatim construct and so may
return false positives.

This function is faster than `TeX-in-comment' and is intended to
be used for repetitive tasks."
  (if (or (bolp)
      (null comment-start-skip))
      nil
    (save-excursion
      (save-match-data
    (skip-chars-backward "^%\n\r")
    (if (bolp)
        nil
      (let ((bol (save-excursion (beginning-of-line) (point))))
        (re-search-backward comment-start-skip bol t)))))))
--8<---------------cut here---------------end--------------->8---
As mentioned in the doc string, it may return false positives but
there should be no false negative.  `TeX-in-comment' isn't perfect
either, it fails to return t if point is at underscore in the
following line
    \verb!%! % _

Bye,
Mosè



reply via email to

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