File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ ### Changes
6
+
5
7
* Indent ` fdef ` (clojure.spec) like a ` def ` .
8
+ * The results of ` clojure-project-dir ` are cached by default to optimize performance.
6
9
7
10
## 5.7.0 (2018-04-29)
8
11
Original file line number Diff line number Diff line change @@ -1629,12 +1629,30 @@ nil."
1629
1629
1630
1630
1631
1631
1632
+ (defcustom clojure-cache-project-dir t
1633
+ " Whether to cache the results of `clojure-project-dir' ."
1634
+ :type 'boolean
1635
+ :safe #'booleanp
1636
+ :package-version '(clojure-mode . " 5.8.0" ))
1637
+
1638
+ (defvar-local clojure-cached-project-dir nil
1639
+ " A project dir cache used to speed up related operations." )
1640
+
1632
1641
(defun clojure-project-dir (&optional dir-name )
1633
1642
" Return the absolute path to the project's root directory.
1634
1643
1635
1644
Call is delegated down to `clojure-project-root-function' with
1636
- optional DIR-NAME as argument."
1637
- (funcall clojure-project-root-function dir-name))
1645
+ optional DIR-NAME as argument.
1646
+
1647
+ When `clojure-cache-project-dir' is t the results of the command
1648
+ are cached in a buffer local variable (`clojure-cached-project-dir' )."
1649
+ (let ((project-dir (or clojure-cached-project-dir
1650
+ (funcall clojure-project-root-function dir-name))))
1651
+ (when (and clojure-cache-project-dir
1652
+ (derived-mode-p 'clojure-mode )
1653
+ (not clojure-cached-project-dir))
1654
+ (setq clojure-cached-project-dir project-dir))
1655
+ project-dir))
1638
1656
1639
1657
(defun clojure-project-root-path (&optional dir-name )
1640
1658
" Return the absolute path to the project's root directory.
Original file line number Diff line number Diff line change 29
29
(let ((project-dir " /home/user/projects/my-project/" )
30
30
(clj-file-path " /home/user/projects/my-project/src/clj/my_project/my_ns/my_file.clj" )
31
31
(project-relative-clj-file-path " src/clj/my_project/my_ns/my_file.clj" )
32
- (clj-file-ns " my-project.my-ns.my-file" ))
32
+ (clj-file-ns " my-project.my-ns.my-file" )
33
+ (clojure-cache-project nil ))
33
34
34
35
(ert-deftest project-relative-path ()
35
36
:tags '(utils)
You can’t perform that action at this time.
0 commit comments