emacs-devel
[Top][All Lists]
Advanced

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

Java: Jump to file from stacktrace


From: Anand Tamariya
Subject: Java: Jump to file from stacktrace
Date: Sun, 18 Apr 2021 20:21:31 +0530

If you need to jump into a file from stacktrace in a log, use the patch in compile.el . Then with an appropriate find-file function, you can easily jump to the location.

(defun gud-compilation-find-file (_marker filename _directory &rest _formats)
  "Find a buffer for file FILENAME."
  (ede-find-file filename))

(setq next-error-function 'compilation-next-error-function
          compilation-locs (make-hash-table :test 'equal :weakness 'value)
          compilation-find-file 'gud-compilation-find-file)


diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 6b39dcd3d5..a21be665f5 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -802,6 +802,7 @@ compilation-disable-input
 ;; value is a FILE-STRUCTURE as described above, with the car eq to the hash
 ;; key.  This holds the tree seen from root, for storing new nodes.
 (defvar compilation-locs ())
+(make-variable-buffer-local 'compilation-locs)
 
 (defvar compilation-debug nil
   "Set this to t before creating a *compilation* buffer.
@@ -2586,7 +2587,7 @@ compilation-next-error-function
       (with-current-buffer
           (if (bufferp (caar (compilation--loc->file-struct loc)))
               (caar (compilation--loc->file-struct loc))
-            (apply #'compilation-find-file
+            (apply compilation-find-file
                    marker
                    (caar (compilation--loc->file-struct loc))
                    (cadr (car (compilation--loc->file-struct loc)))
@@ -2869,6 +2870,10 @@ compilation-goto-locus-delete-o
   (remove-hook 'pre-command-hook
               #'compilation-goto-locus-delete-o))
 ^L
+(defvar compilation-find-file #'compilation-find-file
+  "Function to find a file in compilation buffer.")
+(make-variable-buffer-local 'compilation-find-file)
+
 (defun compilation-find-file (marker filename directory &rest formats)
   "Find a buffer for file FILENAME.
 If FILENAME is not found at all, ask the user where to find it.

reply via email to

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