GNU bug report logs -
#32062
12.1.1; LaTeX-outline-name can't handle long lines or braces in titles
Previous Next
Reported by: Omar <omar.antolin <at> gmail.com>
Date: Thu, 5 Jul 2018 17:01:02 UTC
Severity: normal
Found in version 12.1.1
Done: Arash Esbati <arash <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32062 in the body.
You can then email your comments to 32062 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#32062
; Package
auctex
.
(Thu, 05 Jul 2018 17:01:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Omar <omar.antolin <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-auctex <at> gnu.org
.
(Thu, 05 Jul 2018 17:01:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
I noticed recently that imenu lists the names of section titles incorrectly under AucTeX, while it gives the titles I'd expect under Emacs' builtin tex-mode.el.
I narrowed down the problem to LaTeX-outline-name which gives the wrong answer in two situations:
1. If the section (or subsection, etc.) title is very long, namely, if it ends in a column greater than fill-column plus 10, then LaTeX-outline-name reports the title as the first 20 characters in the line. This is particularly ugly since it means the title will start with "\section{" or somehting like that.
2. If the title contains a right brace, LaTeX-outline-name reports the title as ending at that brace.
This small document illustrates both problems:
\documentclass{article}
\begin{document}
\section{A title so utterly long that it exceeds the fill column by more than ten characters}
\section{Braces \emph{screw} this one up}
\end{document}
If fill-column is set to a reasonable value, the first section is too long and gets listed in imenu as "\section{A title so ". The second one gets truncated at the right brace: "\section{Braces \emph{screw".
The builtin tex-mode uses forward-sexp to allow balanced braces inside the section titles. In my personal configuration I've replace LaTeX-outline-name with:
(defun LaTeX-outline-name ()
"Guess a name for the current header line."
(save-excursion
(search-forward "{" nil t)
(let ((beg (point)))
(forward-char -1)
(condition-case nil
(progn
(forward-sexp 1)
(forward-char -1))
(error (forward-sentence 1)))
(buffer-substring beg (point)))))
This attempts to skip over the title using forward-sexp and in case of error uses forward-sentence instead. It seems to work on the files I noticed had a problem before, but I haven't done extensive testing.
Emacs : GNU Emacs 25.3.2 (i686-pc-linux-gnu, GTK+ Version 3.18.9)
of 2017-09-12
Package: 12.1.1
current state:
==============
(setq
AUCTeX-date "2018-03-20"
window-system 'x
LaTeX-version "2e"
TeX-style-path '("~/.emacs.d/auctex"
"/home/omar/.emacs.d/elpa/auctex-12.1.1/style" "/home/omar/.emacs.d/auctex/auto" "/home/omar/.emacs.d/auctex/style" "auto" "style")
TeX-auto-save nil
TeX-parse-self nil
TeX-master t
TeX-command-list '(("TeX"
"%(PDF)%(tex) %(file-line-error) %(extraopts) %`%S%(PDFout)%(mode)%' %t"
TeX-run-TeX nil
(plain-tex-mode ams-tex-mode
texinfo-mode)
:help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %t"
TeX-run-TeX nil
(latex-mode doctex-mode) :help
"Run LaTeX")
("Makeinfo"
"makeinfo %(extraopts) %t"
TeX-run-compile nil
(texinfo-mode) :help
"Run Makeinfo with Info output")
("Makeinfo HTML"
"makeinfo %(extraopts) --html %t"
TeX-run-compile nil
(texinfo-mode) :help
"Run Makeinfo with HTML output")
("AmSTeX"
"amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
TeX-run-TeX nil (ams-tex-mode)
:help "Run AMSTeX")
("ConTeXt"
"%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
TeX-run-TeX nil (context-mode)
:help "Run ConTeXt once")
("ConTeXt Full"
"%(cntxcom) %(extraopts) %(execopts)%t"
TeX-run-TeX nil (context-mode)
:help
"Run ConTeXt until completion")
("BibTeX" "bibtex %s"
TeX-run-BibTeX nil t :help
"Run BibTeX")
("Biber" "biber %s" TeX-run-Biber
nil t :help "Run Biber")
("View" "%V"
TeX-run-discard-or-function t t
:help "Run Viewer")
("Print" "%p" TeX-run-command t t
:help "Print the file")
("Queue" "%q" TeX-run-background
nil t :help
"View the printer queue" :visible
TeX-queue-command)
("File" "%(o?)dvips %d -o %f "
TeX-run-dvips t t :help
"Generate PostScript file")
("Dvips" "%(o?)dvips %d -o %f "
TeX-run-dvips nil t :help
"Convert DVI file to PostScript")
("Dvipdfmx" "dvipdfmx %d"
TeX-run-dvipdfmx nil t :help
"Convert DVI file to PDF with dvipdfmx")
("Ps2pdf" "ps2pdf %f"
TeX-run-ps2pdf nil t :help
"Convert PostScript file to PDF")
("Glossaries" "makeglossaries %s"
TeX-run-command nil t :help
"Run makeglossaries to create glossary file")
("Index" "makeindex %s"
TeX-run-index nil t :help
"Run makeindex to create index file")
("upMendex" "upmendex %s"
TeX-run-index t t :help
"Run upmendex to create index file")
("Xindy" "texindy %s"
TeX-run-command nil t :help
"Run xindy to create index file")
("Check" "lacheck %s"
TeX-run-compile nil (latex-mode)
:help
"Check LaTeX file for correctness")
("ChkTeX" "chktex -v6 %s"
TeX-run-compile nil (latex-mode)
:help
"Check LaTeX file for common mistakes")
("Spell"
"(TeX-ispell-document \"\")"
TeX-run-function nil t :help
"Spell-check the document")
("Clean" "TeX-clean"
TeX-run-function nil t :help
"Delete generated intermediate files")
("Clean All" "(TeX-clean t)"
TeX-run-function nil t :help
"Delete generated intermediate and output files")
("Other" "" TeX-run-command t t
:help "Run an arbitrary command")
)
)
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#32062
; Package
auctex
.
(Wed, 06 Mar 2024 08:34:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 32062 <at> debbugs.gnu.org (full text, mbox):
Omar <omar.antolin <at> gmail.com> writes:
> Hello,
>
> I noticed recently that imenu lists the names of section titles
> incorrectly under AucTeX, while it gives the titles I'd expect under
> Emacs' builtin tex-mode.el.
>
> I narrowed down the problem to LaTeX-outline-name which gives the
> wrong answer in two situations:
>
> 1. If the section (or subsection, etc.) title is very long, namely, if
> it ends in a column greater than fill-column plus 10, then
> LaTeX-outline-name reports the title as the first 20 characters in the
> line. This is particularly ugly since it means the title will start
> with "\section{" or somehting like that.
>
> 2. If the title contains a right brace, LaTeX-outline-name reports the
> title as ending at that brace.
>
> This small document illustrates both problems:
>
> \documentclass{article}
> \begin{document}
> \section{A title so utterly long that it exceeds the fill column by more than ten characters}
> \section{Braces \emph{screw} this one up}
> \end{document}
>
> If fill-column is set to a reasonable value, the first section is too
> long and gets listed in imenu as "\section{A title so ". The second
> one gets truncated at the right brace: "\section{Braces \emph{screw".
>
> The builtin tex-mode uses forward-sexp to allow balanced braces inside
> the section titles. In my personal configuration I've replace
> LaTeX-outline-name with:
>
> (defun LaTeX-outline-name ()
> "Guess a name for the current header line."
> (save-excursion
> (search-forward "{" nil t)
> (let ((beg (point)))
> (forward-char -1)
> (condition-case nil
> (progn
> (forward-sexp 1)
> (forward-char -1))
> (error (forward-sentence 1)))
> (buffer-substring beg (point)))))
>
> This attempts to skip over the title using forward-sexp and in case of
> error uses forward-sentence instead. It seems to work on the files I
> noticed had a problem before, but I haven't done extensive testing.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
Hi Omar,
first, my sincere apologies that you didn't hear from us in a timely
manner. I'm not an Imenu user, but from a brief test on the file below,
I believe that `LaTeX-outline-name' is currently broken, actually.
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}
\section{A title so utterly long that it exceeds
the fill column by more than ten characters}
\section{A title so utterly}
\section{Braces \emph{screw} this one up}
\section{A title so utterly long that it exceeds the fill column by
more than ten characters}
\section{A Title so utterly long that it exceeds the fill column by more than ten characters}
\end{document}
--8<---------------cut here---------------end--------------->8---
Based on your code, I suggest to change the function to this:
--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---
What do you and others think? Again, sorry for being late.
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#32062
; Package
auctex
.
(Wed, 06 Mar 2024 13:50:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 32062 <at> debbugs.gnu.org (full text, mbox):
Omar Antolín Camarena <omar.antolin <at> gmail.com> 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
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#32062
; Package
auctex
.
(Fri, 08 Mar 2024 10:18:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 32062 <at> debbugs.gnu.org (full text, mbox):
Arash Esbati <arash <at> gnu.org> writes:
> I think I will wait another day or two if there are other comments and
> then install this version:
I installed the change (commit 03a5aac0d7) and therefore closing this
report. Again, sorry it took so long.
Best, Arash
bug closed, send any further explanations to
32062 <at> debbugs.gnu.org and Omar <omar.antolin <at> gmail.com>
Request was from
Arash Esbati <arash <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 08 Mar 2024 10:18:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#32062
; Package
auctex
.
(Fri, 08 Mar 2024 12:25:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 32062 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
No worries, thanks for the fix!
On Fri, Mar 8, 2024, 4:16 AM Arash Esbati <arash <at> gnu.org> wrote:
> Arash Esbati <arash <at> gnu.org> writes:
>
> > I think I will wait another day or two if there are other comments and
> > then install this version:
>
> I installed the change (commit 03a5aac0d7) and therefore closing this
> report. Again, sorry it took so long.
>
> Best, Arash
>
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 06 Apr 2024 11:24:23 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 36 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.