From: Lars Ingebrigtsen Date: Fri, 29 Jan 2021 06:15:35 +0000 (+0100) Subject: flymake-diagnostic-beg/end doc string and error reporting improvement X-Git-Tag: emacs-28.0.90~4053 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9fb859010fa624f4b63ad4a1a8ba22a0f64f16f2;p=emacs.git flymake-diagnostic-beg/end doc string and error reporting improvement * lisp/progmodes/flymake.el (flymake-diagnostic-beg): (flymake-diagnostic-end): Improve doc string and error reporting (bug#39971). --- diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 460af718aad..5d96c62b418 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -352,12 +352,20 @@ diagnostics at BEG." (flymake--diag-accessor flymake-diagnostic-data flymake--diag-data backend) (defun flymake-diagnostic-beg (diag) - "Get Flymake diagnostic DIAG's start position." - (overlay-start (flymake--diag-overlay diag))) + "Get Flymake diagnostic DIAG's start position. +This position only be queried after DIAG has been reported to Flymake." + (let ((overlay (flymake--diag-overlay diag))) + (unless overlay + (error "DIAG %s not reported to Flymake yet" diag)) + (overlay-start overlay))) (defun flymake-diagnostic-end (diag) - "Get Flymake diagnostic DIAG's end position." - (overlay-end (flymake--diag-overlay diag))) + "Get Flymake diagnostic DIAG's end position. +This position only be queried after DIAG has been reported to Flymake." + (let ((overlay (flymake--diag-overlay diag))) + (unless overlay + (error "DIAG %s not reported to Flymake yet" diag)) + (overlay-end overlay))) (cl-defun flymake--overlays (&key beg end filter compare key) "Get flymake-related overlays.