bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29246: Possible solution?


From: Lele Gaifax
Subject: bug#29246: Possible solution?
Date: Fri, 01 Dec 2017 12:06:34 +0100

I'm trying the following, that seems to fix the issue:

  (defun python--flymake-parse-output (source proc report-fn)
    "Collect diagnostics parsing checker tool's output line by line."
    (let ((rx (nth 0 python-flymake-command-output-pattern))
          (lineidx (nth 1 python-flymake-command-output-pattern))
          (colidx (nth 2 python-flymake-command-output-pattern))
          (typeidx (nth 3 python-flymake-command-output-pattern))
          (msgidx (nth 4 python-flymake-command-output-pattern)))
      (with-current-buffer (process-buffer proc)
        (goto-char (point-min))
        (cl-loop
         while (search-forward-regexp rx nil t)
         for msg = (match-string msgidx)
         for (beg . end) = (flymake-diag-region
                            source
                            (string-to-number
                             (match-string lineidx))
                            (and colidx
                                 (match-string colidx)
                                 (string-to-number
                                  (match-string colidx))))
         for type = (or (and typeidx
                             (match-string typeidx)
                             (assoc-default
                              (match-string typeidx)
                              python-flymake-msg-alist
                              #'string-match))
                        (assoc-default msg
                                       python-flymake-msg-alist
                                       #'string-match)
                        :error)
         if (and beg end)
           collect (flymake-make-diagnostic
                    source beg end type msg) into diags
         finally (funcall report-fn diags)))))

where I added an `if (and beg end)' clause around `collect'.

Is that reasonable, or would it be better to make `flymake--highlight-line'
more robust againt a diagnostic with invalid `beg'/`end' slots?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]