Subject: bug#37337: closed (Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on evaporated overlays)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 26 Oct 2019 11:01:02 +0000

Your bug report

#37337: 2019-08-31; Error when `TeX-fold-hide-item' acts on evaporated overlays

which was filed against the auctex package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
37337: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37337
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on evaporated overlays
From: Arash Esbati <[email-masked]>
To: Florent Rougon <[email-masked]>
Cc: [email-masked]
Date: Sat, 26 Oct 2019 13:00:04 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Florent,

Florent Rougon <[email-masked]> writes:

> Arash Esbati <[email-masked]> wrote:
>
>> Many thanks for tracking this down.  I can confirm the bug you describe,
>> and have a question reg. your patch: If it's only about checking if
>> `overlay-start' and `overlay-end' are non-nil, wouldn't it be easier to
>> do:
>>
>>     (when (and ov-start ov-end) ...)
>>
>> instead of
>>
>>     (unless (equal ov-start ov-end) ...)
>
> I don't program in ELisp every day (far from it)

Same here, so no worries :-)

> but AFAIK, the two tests are logically equivalent in this context,
> since the overlay has the 'evaporate' property. But I guess you
> already realized that, just wanted to be clear. So, unless I am
> mistaken, this is only a matter of style. I'm quite fine with your
> test, it puts the emphasis on necessary conditions for the following
> code to behave well, I have no problem with that. :-)

Thanks for your response.  I've installed a modified patch and used most
parts of your ChangeLog entry[1].  Again, thanks for tracking this
down.  I'm closing this report.

Best, Arash

Footnotes:
[1]  http://git.savannah.gnu.org/cgit/auctex.git/commit/?id=342fa714ae53c6e4ffd248310bb201bb97e2a9c0

Subject: 2019-08-31; Error when `TeX-fold-hide-item' acts on evaporated overlays
From: Florent Rougon <[email-masked]>
To: [email-masked]
Date: Sat, 07 Sep 2019 23:37:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Dear AUCTeX maintainers,

First of all, thank you very much for your great work on AUCTeX!

I found a problem when trying to fold comments in a .dtx file (which
seems very useful to me given the verbosity of the .dtx format). It
manifests with the following backtrace:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  TeX-fold-overfull-p(nil nil "…")
  TeX-fold-hide-item(#<overlay in no buffer>)
  TeX-fold-region-comment(1 356)
  TeX-fold-region(1 356)
  TeX-fold-buffer()
  funcall-interactively(TeX-fold-buffer)
  call-interactively(TeX-fold-buffer nil nil)
  command-execute(TeX-fold-buffer)

and can be reproduced this way:

1. Configure AUCTeX to fold comments:

   (setq TeX-fold-type-list '(comment))

2. Visit a buffer containing the attached 'test.dtx' file.

3. Activate TeX-fold-mode (either with `C-c C-o C-f' or from the menus:
   LaTeX -> Show/Hide -> Fold Mode).

4. Fold everything in the current buffer according to
   `TeX-fold-type-list'. This can be done with `C-c C-o C-b'.
   Alternatively, you can trigger the same bug by selecting a region in
   test.dtx that is large enough to contain 'abc%' and 'def', then do
   `C-c C-o C-r' to fold all configured things in the region.

What happens is that when a comment to be folded consists of only the
percent sign, the overlay created by `TeX-fold-make-overlay' immediately
evaporates because its start and end positions are equal. This causes an
error when `TeX-fold-hide-item' calls `TeX-fold-overfull-p`, which tries
to (goto-char) to the overlay end.

The next email in this bug report will contain a patch ready to apply
using:

  git am some-file

after you have saved that email in mbox format to 'some-file'.

Thanks!

Emacs  : GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.10)
 of 2019-07-22, modified by Debian
Package: 2019-08-31

current state:
==============
(setq
 AUCTeX-date "2019-08-31"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("auctex-style" "auctex-auto" "/home/flo/.local/var/auctex"
                  "/home/flo/lisp/manual-installs/auctex/style"
                  "/home/flo/.emacs.d/auctex/auto"
                  "/home/flo/.emacs.d/auctex/style")
 TeX-auto-save t
 TeX-parse-self t
 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
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode context-mode)
                     :help "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :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
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Generate PostScript file")
                    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert DVI file to PostScript")
                    ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert DVI file to PDF with dvipdfmx")
                    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert PostScript file to PDF")
                    ("Glossaries" "makeglossaries %s" TeX-run-command nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run makeglossaries to create glossary\n     file")
                    ("Index" "makeindex %s" TeX-run-index nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run makeindex to create index file")
                    ("upMendex" "upmendex %s" TeX-run-index t
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run upmendex to create index file")
                    ("Xindy" "texindy %s" TeX-run-command nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :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")
                    ("Dvips" "dvips %d -o %f" TeX-run-command nil nil)
                    ("View with xdvi" "%v" TeX-run-silent nil nil)
                    ("View with xdvi -paper a4r" "%v -paper a4r"
                     TeX-run-silent
                     nil nil)
                    ("View with the default PostScript viewer" "see %f"
                     TeX-run-discard nil nil)
                    ("View with gv" "gv %f" TeX-run-discard nil nil)
                    ("View with xpdf" "xpdf %s.pdf" TeX-run-silent nil nil)
                    ("View with okular" "okular %s.pdf" TeX-run-silent nil nil))
 )
-- 
Florent