Subject: bug#70816: 29.2; Flymake fails in latex-mode when the buffer is narrowed

From: Arash Esbati <[email-masked]>
Date: Tue, 07 May 2024 17:19:03 +0200

Vangelis Evangelou <[email-masked]> 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