.emacs-my
changeset 1497 9a881de3da24
parent 1494 874f705f7be4
child 1500 6401d60fd71e
--- a/.emacs-my	Thu Feb 23 08:19:21 2017 +0200
+++ b/.emacs-my	Thu Feb 23 09:59:25 2017 +0200
@@ -3199,6 +3199,37 @@
 (when (and (featurep 'semantic) (featurep 'company))
   (add-hook 'java-mode-hook #'my/company-java-setup))
 
+(defvar my/java-exeption-dirs nil
+  "List of dirs to look by `my/java-exeption'.")
+
+(defun my/java-exeption ()
+  "Look at current line if it like Java exaption and try find file using `my/java-exeption-dirs'"
+  (interactive)
+  (save-excursion
+    (let ( path file line end )
+      (forward-line 1)
+      (backward-char 1)
+      (setq end (point))
+      (forward-line 0)
+      (if (not (re-search-forward "^\\s-+at \\([a-zA-Z0-9.$]+\\)(\\([^.]+\\)\\.java:\\([1-9][0-9]*\\))" end t))
+          (message "Current line doesn't look like Java exeption or lack necessary information...")
+        (setq file (match-string 2))
+        (setq line (match-string 3))
+        (setq path (match-string 1))
+        (setq path (replace-regexp-in-string (concat "\\." file ".*") "" path))
+        (setq path (replace-regexp-in-string "\\." "/" path))
+        (setq path (cl-some (lambda (dir)
+                              (let ((full-path (format "%s/%s/%s.java" dir path file)))
+                                (when (file-exists-p full-path) full-path)))
+                            my/java-exeption-dirs))
+        (if (not path)
+            (message "Can't find file %s.java" file)
+          (find-file-other-window path)
+          (goto-line (string-to-int line)))))))
+
+(my--eval-after-load log4-hi-mode
+  (define-key log4-hi-mode-map [C-return] #'my/java-exeption))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (message "Pascal")