Subject: bug#32062: 12.1.1; LaTeX-outline-name can't handle long lines or braces in titles

From: Arash Esbati <[email-masked]>
Date: Wed, 06 Mar 2024 14:48:56 +0100

Omar Antolín Camarena <[email-masked]> writes:

> The function you propose looks fine to me (I mean, it would, it's very
> similar to what I use!).

Thanks for your respone.

> I guess the point about (TeX-search-syntax-table ?\{ ?\}) is to be
> more lenient about mismatched non-brace delimiters? That's a good
> idea.

Exactly, so that a lonesome ] doesn't get in the way.  One other
addition was the `replace-regexp-in-string' part in order to avoid
linebreaks in the Imenu.  I think I will wait another day or two if
there are other comments and then install this version:

--8<---------------cut here---------------start------------->8---
(defun LaTeX-outline-name ()
  "Guess a name for the current header line."
  (save-excursion
    (search-forward "{" nil t)
    (let ((beg (point)))
      (backward-char)
      (condition-case nil
          (with-syntax-table (TeX-search-syntax-table ?\{ ?\})
            (forward-sexp)
            (backward-char))
        (error (forward-sentence)))
      (replace-regexp-in-string "[\n\r][ ]*" " "
                                (buffer-substring beg (point))))))
--8<---------------cut here---------------end--------------->8---

Best, Arash