summary refs log tree commit diff
path: root/emacs.d/core/core-defun.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs.d/core/core-defun.el')
-rw-r--r--emacs.d/core/core-defun.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/emacs.d/core/core-defun.el b/emacs.d/core/core-defun.el
index 5180e68..be7899f 100644
--- a/emacs.d/core/core-defun.el
+++ b/emacs.d/core/core-defun.el
@@ -39,4 +39,33 @@
         (ansi-term (getenv "SHELL")))
     (switch-to-buffer-other-window "*ansi-term*")))
 
+;; jump to the BUILD file
+(defvar fcuny/build-file "BUILD"
+  "Name of the file containing our build targets")
+
+(defun fcuny/find-root-directory-for-build-file (file)
+  "Find the root."
+  (let ((root nil)
+        try)
+    (while (not (or root
+                    (null file)
+                    (string-match locate-dominating-stop-dir-regexp file)))
+      (setq try (if (stringp fcuny/build-file)
+                    (file-exists-p (expand-file-name fcuny/build-file file))
+                  (message "found file exists -> %s" file)))
+      (cond (try (setq root file))
+            ((equal file (setq file (file-name-directory
+                                     (directory-file-name file))))
+             (setq file nil))))
+    (and root (expand-file-name (file-name-as-directory root)))))
+
+(defun fcuny/jump-to-build-file ()
+  "Open the BUILD file in a buffer if it exists."
+  (interactive)
+  (let ((build-file (fcuny/find-root-directory-for-build-file (file-name-directory (buffer-file-name)))))
+    (message "found a file %s" build-file)
+    (if build-file
+        (find-file (concat build-file fcuny/build-file))
+      (error "Could not find %s" fcuny/build-file))))
+
 (provide 'core-defun)