summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--prog/jao-compilation.el34
2 files changed, 19 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index c531d98..d556e71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.elc
+/media/espotify.el
diff --git a/prog/jao-compilation.el b/prog/jao-compilation.el
index 7efbd63..25a27aa 100644
--- a/prog/jao-compilation.el
+++ b/prog/jao-compilation.el
@@ -1,6 +1,6 @@
;;; jao-compilation.el --- utilities to lauch compilations -*- lexical-binding: t; -*-
-;; Copyright (C) 2020 jao
+;; Copyright (C) 2020, 2021 jao
;; Author: jao <mail@jao.io>
;; Keywords: convenience
@@ -25,7 +25,7 @@
;;; Code:
(defvar jao-compilation-dominating-files nil)
-(defvar jao-compilation-dominating-file-rxs '(".*\\.cabal"))
+(defvar jao-compilation-dominating-file-rxs '(".+\\.cabal"))
(defvar jao-compilation-environment ())
(defun jao-compilation--environment ()
@@ -59,17 +59,17 @@
;;;###autoload
(defun jao-compilation-find-root (file doms)
- (locate-dominating-file file `(lambda (d)
- (when (file-directory-p d)
- (directory-files d nil ,doms)))))
+ (when file
+ (locate-dominating-file file `(lambda (d)
+ (when (file-directory-p d)
+ (directory-files d nil ,doms))))))
;;;###autoload
(defun jao-compilation-root (&optional dir)
- (let* ((fn (or dir (buffer-file-name) default-directory))
- (default-directory
- (expand-file-name
- (jao-compilation-find-root fn jao-compilation-dominating-rx))))
- (let* ((dir (file-name-directory fn))
+ (when-let ((rfn (jao-compilation-find-root (or dir (buffer-file-name))
+ jao-compilation-dominating-rx)))
+ (let* ((default-directory (expand-file-name rfn))
+ (dir (file-name-directory rfn))
(rel-path (jao-path-relative-to dir default-directory)))
(if (and (file-directory-p "build")
(not (file-exists-p "build.xml"))
@@ -79,14 +79,14 @@
;;;###autoload
(defun jao-compilation-root-file ()
- (let ((dir (jao-compilation-root)))
+ (when-let ((dir (jao-compilation-root)))
(car (directory-files dir nil jao-compilation-dominating-rx))))
-(with-eval-after-load "project"
- (defun jao-find-compilation-root (dir)
+;;;###autoload
+(defun jao-find-compilation-root (dir)
+ (when (and (stringp dir) (file-exists-p dir))
(when-let ((root (jao-compilation-root dir)))
- (cons 'transient root)))
- (add-to-list 'project-find-functions #'jao-find-compilation-root))
+ (cons 'transient root))))
;;;###autoload
(defun jao-compilation-env (v)
@@ -108,7 +108,9 @@
(defun jao-compilation-setup ()
(jao-compilation-add-dominating
"Makefile" "makefile" "configure.ac" "bootstrap.sh" "aclocal.m4"
- "project.clj" "build.xml" "pom.xml" "setup.py" "stack.yaml"))
+ "project.clj" "build.xml" "pom.xml" "setup.py" "stack.yaml")
+ (with-eval-after-load "project"
+ (add-to-list 'project-find-functions #'jao-find-compilation-root)))
(provide 'jao-compilation)