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

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

[elpa] externals/consult defcdd2ba3 1/3: consult-compile-error: Set curr


From: ELPA Syncer
Subject: [elpa] externals/consult defcdd2ba3 1/3: consult-compile-error: Set current error when exiting
Date: Sun, 27 Feb 2022 06:57:20 -0500 (EST)

branch: externals/consult
commit defcdd2ba34411eb6f967dcd2a1df4d3316ba04d
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    consult-compile-error: Set current error when exiting
---
 consult-compile.el | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/consult-compile.el b/consult-compile.el
index a53b75b36e..ea32ecbdbd 100644
--- a/consult-compile.el
+++ b/consult-compile.el
@@ -72,16 +72,18 @@
              (loc (get-text-property 0 'consult-compile--loc cand))
              (buffer (marker-buffer marker))
              (default-directory (buffer-local-value 'default-directory 
buffer)))
-    (consult--position-marker
-     ;; taken from compile.el
-     (apply #'compilation-find-file
-            marker
-            (caar (compilation--loc->file-struct loc))
-            (cadar (compilation--loc->file-struct loc))
-            (compilation--file-struct->formats
-             (compilation--loc->file-struct loc)))
-     (compilation--loc->line loc)
-     (compilation--loc->col loc))))
+    (cons
+     (consult--position-marker
+      ;; taken from compile.el
+      (apply #'compilation-find-file
+             marker
+             (caar (compilation--loc->file-struct loc))
+             (cadar (compilation--loc->file-struct loc))
+             (compilation--file-struct->formats
+              (compilation--loc->file-struct loc)))
+      (compilation--loc->line loc)
+      (compilation--loc->col loc))
+     marker)))
 
 (defun consult-compile--compilation-buffers (file)
   "Return a list of compilation buffers relevant to FILE."
@@ -92,6 +94,16 @@
        (and (compilation-buffer-internal-p)
             (file-in-directory-p file default-directory))))))
 
+(defun consult-compile--state ()
+  "Like `consult--jump-state', also setting the current compilation error."
+  (let ((state (consult--jump-state 'consult-preview-error)))
+    (pcase-lambda (`(,cand . ,error) restore)
+      (when (and cand restore)
+        (with-current-buffer (marker-buffer error)
+          (setq compilation-current-error error
+                overlay-arrow-position error)))
+      (funcall state cand restore))))
+
 ;;;###autoload
 (defun consult-compile-error ()
   "Jump to a compilation error in the current buffer.
@@ -116,7 +128,7 @@ preview of the currently selected error."
    :group (consult--type-group consult-compile--narrow)
    :narrow (consult--type-narrow consult-compile--narrow)
    :history '(:input consult-compile--history)
-   :state (consult--jump-state 'consult-preview-error)))
+   :state (consult-compile--state)))
 
 (provide 'consult-compile)
 ;;; consult-compile.el ends here



reply via email to

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