emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ivy-hydra fb6db46 093/395: counsel.el (counsel-flycheck


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra fb6db46 093/395: counsel.el (counsel-flycheck-occur): Add
Date: Thu, 25 Feb 2021 08:31:38 -0500 (EST)

branch: externals/ivy-hydra
commit fb6db466915a058139e2ea2c427474930fe6788d
Author: Rudi Grinberg <me@rgrinberg.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el (counsel-flycheck-occur): Add
    
    Fixes #2404
---
 counsel.el | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/counsel.el b/counsel.el
index ea1374a..3553dbe 100644
--- a/counsel.el
+++ b/counsel.el
@@ -6334,9 +6334,36 @@ Local bindings (`counsel-mode-map'):
               (flycheck-error-message error)) 'error error))
    flycheck-current-errors))
 
+(defun counsel-flycheck-occur (cands)
+  "Generate a custom occur buffer for `counsel-flycheck'."
+  (require 'thingatpt)
+  (unless cands
+    (message "need to handle empty cands"))
+  (unless (eq major-mode 'ivy-occur-grep-mode)
+    (ivy-occur-grep-mode)
+    (setq default-directory (ivy-state-directory ivy-last)))
+  (swiper--occur-insert-lines
+   (mapcar
+    (lambda (cand)
+      (let ((err (get-text-property 0 'error cand)))
+        (propertize
+         (format
+          "%s:%d:%s"
+          (flycheck-error-filename err)
+          (flycheck-error-line err)
+          (save-excursion
+            (with-current-buffer (flycheck-error-buffer err)
+              (goto-line (flycheck-error-line err))
+              (string-trim (thing-at-point 'line)))))
+         'error err)))
+    cands)))
+
 (defun counsel-flycheck-errors-action (error)
   (flycheck-jump-to-error (get-text-property 0 'error error)))
 
+(ivy-configure 'counsel-flycheck
+  :occur #'counsel-flycheck-occur)
+
 ;;;###autoload
 (defun counsel-flycheck ()
   "Flycheck errors."



reply via email to

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