summaryrefslogtreecommitdiffhomepage
path: root/prog
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-01-09 01:09:29 +0000
committerjao <jao@gnu.org>2021-01-09 01:09:29 +0000
commit1228164acf5bd3afcda3ab0cba761adccf34c88c (patch)
tree490243089473826a84b2e1d171f398559313c6e2 /prog
parent87607971a317700a179b416c1e2c55d6e6acd854 (diff)
downloadelibs-1228164acf5bd3afcda3ab0cba761adccf34c88c.tar.gz
elibs-1228164acf5bd3afcda3ab0cba761adccf34c88c.tar.bz2
compilation: fixes to not break anything with jao-compilation-root
Diffstat (limited to 'prog')
-rw-r--r--prog/jao-compilation.el34
1 files changed, 18 insertions, 16 deletions
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)