branch: externals/auctex
commit 03a5aac0d7843b8e89701d73b29eb02d5654db28
Author: Arash Esbati <[email protected]>
Commit: Arash Esbati <[email protected]>
Improve guessing a name for the current header line
* latex.el (LaTeX-outline-name): Handle long titles and the ones
with balanced braces correctly. (bug#32062)
Co-authored-by: Omar Antolin Camarena <[email protected]>
---
latex.el | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/latex.el b/latex.el
index 3e3452a4d3..36177c4847 100644
--- a/latex.el
+++ b/latex.el
@@ -366,9 +366,16 @@ If so, return the second element, otherwise return nil."
(defun LaTeX-outline-name ()
"Guess a name for the current header line."
(save-excursion
- (if (re-search-forward "{\\([^}]*\\)}" (+ (point) fill-column 10) t)
- (match-string 1)
- (buffer-substring (point) (min (point-max) (+ 20 (point)))))))
+ (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))))))
(add-hook 'TeX-remove-style-hook
(lambda () (setq LaTeX-largest-level nil)))