Subject: Re: bug#41564: Auctex on elpa, dated may 24th 2020 is broken

From: Marco Falconi <[email-masked]>
Date: Fri, 29 May 2020 07:56:41 +0200

Hi Tassilo,

Yes I have this function in my .emacs (since very long time, I forgot about that, I
probably copied it from some source).

The full functions are as pasted below. Can you give me some hint on how shall I modify
them?

All the best,
_____
Marco

(defcustom font-latex-lemma-environments
  '("theorem" "lemma")
  "List of lemma-like environment names for font locking."
  :type '(repeat string)
  :group 'font-latex)

(add-hook 'LaTeX-mode-hook
          (lambda ()
(defun font-latex-match-lemma-envII (limit)
  "Match lemma patterns up to LIMIT.
Used for patterns like:
\\begin{equation}
 fontified stuff
\\end{equation}
The \\begin{equation} and \\end{equation} are not fontified here."
  (when (re-search-forward (concat "\\\\begin[ \t]*{"
                   (regexp-opt font-latex-lemma-environments t)
                   "\\*?}")
               limit t)
    (let ((beg (match-end 0)) end)
      (if (re-search-forward (concat "\\\\end[ \t]*{"
                     (regexp-quote
                      (buffer-substring-no-properties
                       (match-beginning 1)
                       (match-end 0))))
                 ;; XXX: Should this rather be done by
                 ;; extending the region to be fontified?
                 (+ limit font-latex-multiline-boundary) 'move)
          (setq end (match-beginning 0))
    (goto-char beg)
        (setq end beg))
      (font-latex-put-multiline-property-maybe beg end)
      (store-match-data (list beg end))
      t)))

(defun font-latex-extend-region-backwards-lemma-envII (beg end)
  "Return position to extend region backwards for lemma environments.
Return nil if region does not have to be extended for a multiline
environment to fit in.  The region between the positions BEG and
END marks boundaries for searching for environment ends."
  (save-excursion
    (goto-char end)
    (catch 'extend
      (while (re-search-backward
          (concat "\\\\end[ \t]*{"
              (regexp-opt font-latex-lemma-environments t)
              "\\*?}") beg t)
    (when (and (re-search-backward (concat  "\\\\begin[ \t]*{"
                        (buffer-substring-no-properties
                         (match-beginning 1)
                         (match-end 0)))
                       (- beg font-latex-multiline-boundary) t)
           (< (point) beg))
      (throw 'extend (point))))
      nil)))

(add-to-list 'font-latex-keywords-2 '(font-latex-match-lemma-envII (0 'font-latex-doctex-documentation-face t t)))
(add-to-list 'font-latex-extend-region-functions 'font-latex-extend-region-backwards-lemma-envII)
))

Tassilo Horn <[email-masked]> writes:

> Marco Falconi <[email-masked]> writes:
>
> Hi Marco,
>
>> I attach here both the debugger backtrace report, and the system
>> information, as you asked.
>>
>> Hope it helps.
>
> It does.
>
>> Debugger entered--Lisp error: (void-variable font-latex-extend-region-functions)
>>   (member (quote font-latex-extend-region-backwards-lemma-envII)
>>   font-latex-extend-region-functions)
>
> Indeed, we have restructured quite a lot in font-latex.el in the last
> ELPA release, and now font-latex-extend-region-functions is gone.
> However, there is no font-latex-extend-region-backwards-lemma-envII in
> AUCTeX.  Do you use some extension package providing that function?  Or
> is that in your ~/.emacs?
>
> Bye,
> Tassilo