Skip to content

Commit

Permalink
Don't rely on flymake internals. Fix compatibility with edge Emacs (#…
Browse files Browse the repository at this point in the history
…16)

`flymake' bundled with the edge/master branch version of Emacs no
longer provides the `flymake--overlays' function[^1], which breaks the
core functionality of this package.

Even though overlays are now available via
`flymake--really-all-overlays' (as seen in the linked commit), I
thought it was best to stick to the public API functions. I don't
really know elisp, so hopefully my assumption that functions with `--`
in their name are internal (i.e. not part of the public API) is
correct.

[^1]: emacs-mirror/emacs@5792ea1
  • Loading branch information
Lysander6 authored Dec 24, 2023
1 parent cabe592 commit 7323a37
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions flymake-languagetool.el
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,20 @@ STATUS provided from `url-retrieve'."
(format "Cannot reach LanguageTool URL: %s"
flymake-languagetool-url)))))

(defun flymake-languagetool--overlay-p (overlay)
"Return t if OVERLAY is a `flymake-languagetool' diagnostic overlay."
(when-let* ((diag (overlay-get overlay 'flymake-diagnostic))
(backend (flymake-diagnostic-backend diag)))
(eq backend 'flymake-languagetool--checker)))

(defun flymake-languagetool--ovs (&optional format)
"List of all `flymake-languagetool' diagnostic overlays."
(let* ((n 1)
(ovs (flymake--overlays
:filter (lambda (ov)
(when-let ((diag (overlay-get ov 'flymake-diagnostic)))
(eq (flymake-diagnostic-backend diag)
'flymake-languagetool--checker)))
:compare (if (cl-plusp n) #'< #'>)
:key #'overlay-start)))
(lt-ovs (seq-filter #'flymake-languagetool--overlay-p
(overlays-in (point-min) (point-max))))
(ovs (seq-sort-by #'overlay-start
(if (cl-plusp n) #'< #'>)
lt-ovs)))
(if format
(seq-map
(lambda (ov) (cons (format "%s: %s"
Expand All @@ -414,13 +418,8 @@ STATUS provided from `url-retrieve'."
(defun flymake-languagetool--ov-at-point ()
"Return `flymake-languagetool' overlay at point."
(setq flymake-languagetool-current-cand
(car (flymake--overlays
:beg (point)
:filter
(lambda (ov)
(let ((diag (overlay-get ov 'flymake-diagnostic)))
(eq (flymake-diagnostic-backend diag)
'flymake-languagetool--checker)))))))
(car (seq-filter #'flymake-languagetool--overlay-p
(overlays-at (point))))))

(defun flymake-languagetool--suggestions ()
"Show corrections suggested from LanguageTool."
Expand Down

0 comments on commit 7323a37

Please sign in to comment.