GNU bug report logs - #37337
2019-08-31; Error when `TeX-fold-hide-item' acts on evaporated overlays

Previous Next

Package: auctex;

Reported by: Florent Rougon <f.rougon <at> free.fr>

Date: Sat, 7 Sep 2019 21:38:01 UTC

Severity: normal

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 37337 in the body.
You can then email your comments to 37337 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Sat, 07 Sep 2019 21:38:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Florent Rougon <f.rougon <at> free.fr>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Sat, 07 Sep 2019 21:38:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: bug-auctex <at> gnu.org
Subject: 2019-08-31;
 Error when `TeX-fold-hide-item' acts on evaporated overlays
Date: Sat, 07 Sep 2019 23:37:14 +0200
[Message part 1 (text/plain, inline)]
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
[test.dtx (text/x-tex, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Sat, 07 Sep 2019 21:46:02 GMT) Full text and rfc822 format available.

Message #8 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: 37337 <at> debbugs.gnu.org
Subject: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on evaporated
 overlays
Date: Sat, 7 Sep 2019 19:24:47 +0200
* tex-fold.el (TeX-fold-hide-item): wrap the end of the function in
(unless (equal ov-start ov-end) ...). What is done in this part isn't
useful with evaporated overlays and used to cause bugs because
`overlay-start' and `overlay-end' return nil for such overlays, and
functions such as `TeX-fold-overfull-p` try to move point to the
overlay-end. Fixes bug#37337.
---
 tex-fold.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/tex-fold.el b/tex-fold.el
index f66776de..76d6319a 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -811,23 +811,25 @@ That means, put respective properties onto overlay OV."
 			   "[Error: No content found]"))))
 	 (display-string (if (listp computed) (car computed) computed))
 	 (face (when (listp computed) (cadr computed))))
-    ;; Cater for zero-length display strings.
-    (when (string= display-string "") (setq display-string TeX-fold-ellipsis))
-    ;; Add a linebreak to the display string and adjust the overlay end
-    ;; in case of an overfull line.
-    (when (TeX-fold-overfull-p ov-start ov-end display-string)
-      (setq display-string (concat display-string "\n"))
-      (move-overlay ov ov-start (save-excursion
-				  (goto-char ov-end)
-				  (skip-chars-forward " \t")
-				  (point))))
-    (overlay-put ov 'mouse-face 'highlight)
-    (overlay-put ov 'display display-string)
-    (when font-lock-mode
-      (overlay-put ov 'face TeX-fold-folded-face))
-    (unless (zerop TeX-fold-help-echo-max-length)
-      (overlay-put ov 'help-echo (TeX-fold-make-help-echo
-				  (overlay-start ov) (overlay-end ov))))))
+    ;; Do nothing if the overlay is empty
+    (unless (equal ov-start ov-end)
+      ;; Cater for zero-length display strings.
+      (when (string= display-string "") (setq display-string TeX-fold-ellipsis))
+      ;; Add a linebreak to the display string and adjust the overlay end
+      ;; in case of an overfull line.
+      (when (TeX-fold-overfull-p ov-start ov-end display-string)
+        (setq display-string (concat display-string "\n"))
+        (move-overlay ov ov-start (save-excursion
+				    (goto-char ov-end)
+				    (skip-chars-forward " \t")
+				    (point))))
+      (overlay-put ov 'mouse-face 'highlight)
+      (overlay-put ov 'display display-string)
+      (when font-lock-mode
+        (overlay-put ov 'face TeX-fold-folded-face))
+      (unless (zerop TeX-fold-help-echo-max-length)
+        (overlay-put ov 'help-echo (TeX-fold-make-help-echo
+				    (overlay-start ov) (overlay-end ov)))))))
 
 (defun TeX-fold-show-item (ov)
   "Show a single LaTeX macro or environment.
-- 
2.23.0





Information forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Sat, 07 Sep 2019 22:01:01 GMT) Full text and rfc822 format available.

Message #11 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: 37337 <at> debbugs.gnu.org
Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on
 evaporated overlays
Date: Sun, 08 Sep 2019 00:00:06 +0200
Well, since the list software or bug tracking system automatically
changes the email Subject field, after saving the mail and before
running 'git am', you may want to replace its Subject with:

[PATCH] Fix bug in `TeX-fold-hide-item' when acting on evaporated overlays

i.e., remove the automatically-added prefix 'bug#37337: ', otherwise it
will appear along with '[PATCH] ' in the first line of the commit
message...

Thanks & regards

-- 
Florent




Information forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Sat, 07 Sep 2019 22:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: 37337 <at> debbugs.gnu.org
Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on
 evaporated overlays
Date: Sun, 08 Sep 2019 00:08:26 +0200
The 'mbox' link at:

  https://debbugs.gnu.org/cgi/bugreport.cgi?mbox=yes;bug=37337;msg=8

has the mail intact with its original Subject, so the file from this
link can be applied directly with 'git am' (assuming the fix I found
suits you!). Thus, it must be the mailing-list software that prepended
the 'bug#37337: ' string.

Regards

-- 
Florent




Information forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Thu, 24 Oct 2019 19:52:01 GMT) Full text and rfc822 format available.

Message #17 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Florent Rougon <f.rougon <at> free.fr>
Cc: 37337 <at> debbugs.gnu.org
Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting
 on evaporated overlays
Date: Thu, 24 Oct 2019 21:50:19 +0200
Hi Florent,

Florent Rougon <f.rougon <at> free.fr> writes:

> * tex-fold.el (TeX-fold-hide-item): wrap the end of the function in
> (unless (equal ov-start ov-end) ...). What is done in this part isn't
> useful with evaporated overlays and used to cause bugs because
> `overlay-start' and `overlay-end' return nil for such overlays, and
> functions such as `TeX-fold-overfull-p` try to move point to the
> overlay-end. Fixes bug#37337.

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) ...)

?
Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#37337; Package auctex. (Thu, 24 Oct 2019 21:25:02 GMT) Full text and rfc822 format available.

Message #20 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: 37337 <at> debbugs.gnu.org
Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on
 evaporated overlays
Date: Thu, 24 Oct 2019 23:20:03 +0200
Hi Arash,

Arash Esbati <arash <at> gnu.org> 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) 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 & regards

-- 
Florent




Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Sat, 26 Oct 2019 11:01:01 GMT) Full text and rfc822 format available.

Notification sent to Florent Rougon <f.rougon <at> free.fr>:
bug acknowledged by developer. (Sat, 26 Oct 2019 11:01:02 GMT) Full text and rfc822 format available.

Message #25 received at 37337-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Florent Rougon <f.rougon <at> free.fr>
Cc: 37337-done <at> debbugs.gnu.org
Subject: Re: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting
 on evaporated overlays
Date: Sat, 26 Oct 2019 13:00:04 +0200
Hi Florent,

Florent Rougon <f.rougon <at> free.fr> writes:

> Arash Esbati <arash <at> gnu.org> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 23 Nov 2019 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 149 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.