GNU bug report logs -
#70816
29.2; Flymake fails in latex-mode when the buffer is narrowed
Previous Next
To reply to this bug, email your comments to 70816 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Tue, 07 May 2024 07:58:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Vangelis Evangelou <evangelou <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 07 May 2024 07:58:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
With the buffer having the contents shown below,
1. Enable flymake-mode.
2. Narrow from the top of the buffer down to the indicated comment.
3. Execute flymake-start.
You should get an error "error in process sentinel: Wrong type argument:
integer-or-marker-p, nil". I suspect perl-flymake has similar issues so you
might want to check that out as well.
Buffer contents:
\documentclass{article}
\begin{document}
0
a
b
c
% <----- End narrow
d
e
f
g
h
i
j{
\end{document}
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Tue, 07 May 2024 15:20:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 70816 <at> debbugs.gnu.org (full text, mbox):
Vangelis Evangelou <evangelou <at> gmail.com> writes:
> With the buffer having the contents shown below,
> 1. Enable flymake-mode.
> 2. Narrow from the top of the buffer down to the indicated comment.
> 3. Execute flymake-start.
The reproducer for me was to save a file like this (note the first blank
lines):
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}
0
a
b
cf
% <----- End narrow
d
e
f
g
h
i
j{
\end{document}
--8<---------------cut here---------------end--------------->8---
Then:
• emacs -Q
• M-x toggle-debug-on-error RET
• Visit the file, M-x flymake-mode RET
• Mark '\document... End narrow' and hit 'C-x n n'
• Put point after c and hit f
This is what the debugger says (linebreaks added manually):
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
make-overlay(nil nil)
flymake--highlight-line(#s(flymake--diag :locus #<buffer
flymake-test.tex> :beg nil :end nil :type :warning :text "No match
found for `{'." :backend tex-chktex :data nil :overlay-properties nil
:overlay nil :orig-beg nil :orig-end nil))
flymake--publish-diagnostics((#s(flymake--diag :locus #<buffer
flymake-test.tex> :beg nil :end nil :type :warning :text "No match
found for `{'." :backend tex-chktex :data nil :overlay-properties nil
:overlay nil :orig-beg nil :orig-end nil) #s(flymake--diag :locus
#<buffer flymake-test.tex> :beg 54 :end 73 :type :warning :text
"Number of `{' doesn't match the number of `}'!" :backend tex-chktex
:data nil :overlay-properties nil :overlay nil :orig-beg 54 :orig-end
73)) :backend tex-chktex :state #s(flymake--state :running
backend-token1 :reported-p nil :disabled nil :diags (#s(flymake--diag
:locus #<buffer flymake-test.tex> :beg nil :end nil :type :warning
:text "No match found for `{'." :backend tex-chktex :data nil
:overlay-properties nil :overlay nil :orig-beg nil :orig-end nil))
:foreign-diags #<hash-table eql 0/0 0x43d74c56 ...>) :region nil)
flymake--handle-report(tex-chktex backend-token1 (#s(flymake--diag
:locus #<buffer flymake-test.tex> :beg nil :end nil :type :warning
:text "No match found for `{'." :backend tex-chktex :data nil
:overlay-properties nil :overlay nil :orig-beg nil :orig-end nil)
#s(flymake--diag :locus #<buffer flymake-test.tex> :beg 54 :end 73
:type :warning :text "Number of `{' doesn't match the number of `}'!"
:backend tex-chktex :data nil :overlay-properties nil :overlay nil
:orig-beg 54 :orig-end 73)))
apply(flymake--handle-report tex-chktex backend-token1
(#s(flymake--diag :locus #<buffer flymake-test.tex> :beg nil :end nil
:type :warning :text "No match found for `{'." :backend tex-chktex
:data nil :overlay-properties nil :overlay nil :orig-beg nil :orig-end
nil) #s(flymake--diag :locus #<buffer flymake-test.tex> :beg 54 :end
73 :type :warning :text "Number of `{' doesn't match the number of
`}'!" :backend tex-chktex :data nil :overlay-properties nil :overlay
nil :orig-beg 54 :orig-end 73)))
#f(compiled-function (&rest args) #<bytecode
-0x16dfa1c308597683>)((#s(flymake--diag :locus #<buffer
flymake-test.tex> :beg nil :end nil :type :warning :text "No match
found for `{'." :backend tex-chktex :data nil :overlay-properties nil
:overlay nil :orig-beg nil :orig-end nil) #s(flymake--diag :locus
#<buffer flymake-test.tex> :beg 54 :end 73 :type :warning :text
"Number of `{' doesn't match the number of `}'!" :backend tex-chktex
:data nil :overlay-properties nil :overlay nil :orig-beg 54 :orig-end
73)))
#f(compiled-function (process event) #<bytecode
-0x13a3e83da652160>)(#<process tex-chktex> "finished\n")
--8<---------------cut here---------------end--------------->8---
Best, Arash
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Sat, 18 May 2024 08:43:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 70816 <at> debbugs.gnu.org (full text, mbox):
> Cc: 70816 <at> debbugs.gnu.org
> From: Arash Esbati <arash <at> gnu.org>
> Date: Tue, 07 May 2024 17:19:03 +0200
>
> Vangelis Evangelou <evangelou <at> gmail.com> writes:
>
> > With the buffer having the contents shown below,
> > 1. Enable flymake-mode.
> > 2. Narrow from the top of the buffer down to the indicated comment.
> > 3. Execute flymake-start.
>
> The reproducer for me was to save a file like this (note the first blank
> lines):
>
> --8<---------------cut here---------------start------------->8---
>
>
>
> \documentclass{article}
> \begin{document}
> 0
> a
> b
> cf
> % <----- End narrow
> d
> e
> f
> g
> h
> i
> j{
> \end{document}
> --8<---------------cut here---------------end--------------->8---
>
> Then:
>
> • emacs -Q
> • M-x toggle-debug-on-error RET
> • Visit the file, M-x flymake-mode RET
> • Mark '\document... End narrow' and hit 'C-x n n'
> • Put point after c and hit f
Spencer, can you please look into this?
>
> This is what the debugger says (linebreaks added manually):
>
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
> make-overlay(nil nil)
> flymake--highlight-line(#s(flymake--diag :locus #<buffer
> flymake-test.tex> :beg nil :end nil :type :warning :text "No match
> found for `{'." :backend tex-chktex :data nil :overlay-properties nil
> :overlay nil :orig-beg nil :orig-end nil))
> flymake--publish-diagnostics((#s(flymake--diag :locus #<buffer
> flymake-test.tex> :beg nil :end nil :type :warning :text "No match
> found for `{'." :backend tex-chktex :data nil :overlay-properties nil
> :overlay nil :orig-beg nil :orig-end nil) #s(flymake--diag :locus
> #<buffer flymake-test.tex> :beg 54 :end 73 :type :warning :text
> "Number of `{' doesn't match the number of `}'!" :backend tex-chktex
> :data nil :overlay-properties nil :overlay nil :orig-beg 54 :orig-end
> 73)) :backend tex-chktex :state #s(flymake--state :running
> backend-token1 :reported-p nil :disabled nil :diags (#s(flymake--diag
> :locus #<buffer flymake-test.tex> :beg nil :end nil :type :warning
> :text "No match found for `{'." :backend tex-chktex :data nil
> :overlay-properties nil :overlay nil :orig-beg nil :orig-end nil))
> :foreign-diags #<hash-table eql 0/0 0x43d74c56 ...>) :region nil)
> flymake--handle-report(tex-chktex backend-token1 (#s(flymake--diag
> :locus #<buffer flymake-test.tex> :beg nil :end nil :type :warning
> :text "No match found for `{'." :backend tex-chktex :data nil
> :overlay-properties nil :overlay nil :orig-beg nil :orig-end nil)
> #s(flymake--diag :locus #<buffer flymake-test.tex> :beg 54 :end 73
> :type :warning :text "Number of `{' doesn't match the number of `}'!"
> :backend tex-chktex :data nil :overlay-properties nil :overlay nil
> :orig-beg 54 :orig-end 73)))
> apply(flymake--handle-report tex-chktex backend-token1
> (#s(flymake--diag :locus #<buffer flymake-test.tex> :beg nil :end nil
> :type :warning :text "No match found for `{'." :backend tex-chktex
> :data nil :overlay-properties nil :overlay nil :orig-beg nil :orig-end
> nil) #s(flymake--diag :locus #<buffer flymake-test.tex> :beg 54 :end
> 73 :type :warning :text "Number of `{' doesn't match the number of
> `}'!" :backend tex-chktex :data nil :overlay-properties nil :overlay
> nil :orig-beg 54 :orig-end 73)))
> #f(compiled-function (&rest args) #<bytecode
> -0x16dfa1c308597683>)((#s(flymake--diag :locus #<buffer
> flymake-test.tex> :beg nil :end nil :type :warning :text "No match
> found for `{'." :backend tex-chktex :data nil :overlay-properties nil
> :overlay nil :orig-beg nil :orig-end nil) #s(flymake--diag :locus
> #<buffer flymake-test.tex> :beg 54 :end 73 :type :warning :text
> "Number of `{' doesn't match the number of `}'!" :backend tex-chktex
> :data nil :overlay-properties nil :overlay nil :orig-beg 54 :orig-end
> 73)))
> #f(compiled-function (process event) #<bytecode
> -0x13a3e83da652160>)(#<process tex-chktex> "finished\n")
> --8<---------------cut here---------------end--------------->8---
>
> Best, Arash
>
>
>
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Sat, 18 May 2024 14:52:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 70816 <at> debbugs.gnu.org (full text, mbox):
Can you test with the following patch, please?
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ef190ff0cb5..146aae06253 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -430,6 +430,8 @@ flymake-diag-region
(let ((line (min (max line 1)
(line-number-at-pos (point-max) 'absolute))))
(save-excursion
+ (save-restriction
+ (widen)
(save-match-data
(goto-char (point-min))
(forward-line (1- line))
@@ -463,7 +465,7 @@ flymake-diag-region
(fallback-eol beg))))
(let* ((beg (fallback-bol))
(end (fallback-eol beg)))
- (cons beg end))))))))
+ (cons beg end)))))))))
(error (flymake-log :warning "Invalid region line=%s col=%s" line col)
nil)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Sat, 18 May 2024 14:59:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 70816 <at> debbugs.gnu.org (full text, mbox):
Spencer Baugh <sbaugh <at> janestreet.com> writes:
> Can you test with the following patch, please?
Context:
It looks like the latex-mode flymake diagnostic function, tex-chktex,
widens before sending the buffer contents to the external linter
process. So the line numbers of errors are reported relative to the
widened buffer, not the narrowed buffer. A number of different checkers
in Emacs seem to do the same thing.
The bug is that these checkers call flymake-diag-region to translate the
line numbers into buffer positions. But flymake-diag-region does not
widen the buffer when doing this translation, so it fails.
I expect you have some flymake logs of the form "Invalid region line=%s
col=%s". when triggering this bug.
Probably the right fix in flymake is to make flymake-diag-region widen,
as in the patch I posted, but that's a bit of a behavior change... will
think about it, but it's probably fine.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70816
; Package
emacs
.
(Sat, 18 May 2024 17:14:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 70816 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Spencer.
Yes, that does resolve the issue. However, as you hinted, it causes issues
with other diagnostic functions. In my tests, `ess-r-flymake' from the
emacs speaks statistics (ess) package produces incorrect error positions. I
wonder if `flymake-diag-region' should have an optional argument to not
widen the buffer before calculating the positions.
Best,
Vangelis
On Sat, 18 May 2024 at 15:58, Spencer Baugh <sbaugh <at> janestreet.com> wrote:
> Spencer Baugh <sbaugh <at> janestreet.com> writes:
> > Can you test with the following patch, please?
>
> Context:
>
> It looks like the latex-mode flymake diagnostic function, tex-chktex,
> widens before sending the buffer contents to the external linter
> process. So the line numbers of errors are reported relative to the
> widened buffer, not the narrowed buffer. A number of different checkers
> in Emacs seem to do the same thing.
>
> The bug is that these checkers call flymake-diag-region to translate the
> line numbers into buffer positions. But flymake-diag-region does not
> widen the buffer when doing this translation, so it fails.
>
> I expect you have some flymake logs of the form "Invalid region line=%s
> col=%s". when triggering this bug.
>
> Probably the right fix in flymake is to make flymake-diag-region widen,
> as in the patch I posted, but that's a bit of a behavior change... will
> think about it, but it's probably fine.
>
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 87 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.