Document that flymake-diag-region saves match data

The typical use of this function (which is parsing compiler diagnostic
messages), lends itself too easily to one the problems in bug#29193.
Make it a friendlier API.

* doc/misc/flymake.texi (Flymake utility functions): Document that
flymake-diag-region saves match data.

* lisp/progmodes/flymake.el (flymake-diag-region): Document that
this saves match data.
This commit is contained in:
João Távora 2020-12-18 15:38:27 +00:00
parent eeade2b647
commit fdaaf886b7
2 changed files with 2 additions and 2 deletions

View file

@ -581,7 +581,7 @@ can use the following function:
Compute @var{buffer}'s region (@var{beg} . @var{end}) corresponding
to @var{line} and @var{col}. If @var{col} is @code{nil}, return a
region just for @var{line}. Return @code{nil} if the region is
invalid.
invalid. This function saves match data (@pxref{Saving Match Data}).
@end deffn
@cindex add a log message

View file

@ -412,7 +412,7 @@ verify FILTER, a function, and sort them by COMPARE (using KEY)."
(defun flymake-diag-region (buffer line &optional col)
"Compute BUFFER's region (BEG . END) corresponding to LINE and COL.
If COL is nil, return a region just for LINE. Return nil if the
region is invalid."
region is invalid. This function saves match data."
(condition-case-unless-debug _err
(with-current-buffer buffer
(let ((line (min (max line 1)