Browse files

make project-index use the file-list-cache of the parent

- instead of creating a new one for every sub-project
- mk-proj-get-cache-path modified so copying the cache from the parent
  is optional, or a completely new file can be created
  • Loading branch information...
1 parent 423bcf4 commit bc2d1b9f5e6c852dab01c984c926fc7d275fa730 @rakete committed Sep 29, 2012
Showing with 32 additions and 13 deletions.
  1. +3 −1 mk-project-sourcemarker.el
  2. +29 −12 mk-project.el
@@ -30,7 +30,9 @@
(add-to-list 'mk-proj-var-before-get-functions
'(sourcemarker-db-path . (lambda (var val &optional proj-name config-alist)
(if mk-sourcemarker-per-project-db
- (mk-proj-var-get-cache-path 'sourcemarker-db val)
+ (if val
+ (expand-file-name val)
+ (mk-proj-get-cache-path 'sourcemarker-db nil 'copy))
(or (and val (expand-file-name val))
(add-to-list 'mk-proj-var-before-get-functions
@@ -114,16 +114,26 @@ See also `mk-proj-required-vars' `mk-proj-var-before-get-functions'")
(when (stringp val)
(expand-file-name val)))
-(defun mk-proj-var-get-cache-path (var val &optional proj-name config-alist)
+(defun mk-proj-var-get-tags-file (var val &optional proj-name config-alist)
+ (if val
+ (expand-file-name val)
+ (mk-proj-get-cache-path var proj-name 'copy)))
+(defun mk-proj-var-get-open-file-cache (var val &optional proj-name config-alist)
(if val
(expand-file-name val)
(mk-proj-get-cache-path var proj-name)))
+(defun mk-proj-var-get-file-list-cache (var val &optional proj-name config-alist)
+ (if val
+ (expand-file-name val)
+ (mk-proj-get-cache-path var proj-name t)))
(defvar mk-proj-var-before-get-functions '((basedir . mk-proj-var-expand)
- (tags-file . mk-proj-var-get-cache-path)
- (file-list-cache . mk-proj-var-get-cache-path)
- (open-files-cache . mk-proj-var-get-cache-path)
- (open-friends-cache . mk-proj-var-get-cache-path))
+ (tags-file . mk-proj-var-get-tags-file)
+ (file-list-cache . mk-proj-var-get-file-list-cache)
+ (open-files-cache . mk-proj-var-get-open-file-cache)
+ (open-friends-cache . mk-proj-var-get-open-file-cache))
"Config vars from `mk-proj-required-vars' and `mk-proj-optional-vars' (except 'name')
can be associated with a function in this association list, which will be
applied to the value of the var right after it is taken from the config-alist.
@@ -517,7 +527,7 @@ Examples:
return nil
finally return t))
(when (and (directory-files (apply 'concat (mapcar (lambda (s) (concat "/" s)) (reverse xs))) nil re)
- (eq (some (lambda (re) (string-match re (car xs))) ignore-paths) nil))
+ (not (some (lambda (re) (string-match re (car xs))) ignore-paths)))
(return-from "mk-proj-search-path" (apply 'concat (mapcar (lambda (s) (concat "/" s)) (reverse xs)))))
(setq xs (cdr xs)))))
@@ -1471,7 +1481,7 @@ See also `mk-proj-config-save-section', `mk-proj-config-save-section'"
(unless (mk-proj-get-config-val v proj-name t)
(throw 'mk-proj-check-required-vars v)))))
-(defun mk-proj-get-cache-path (symbol &optional proj-name)
+(defun mk-proj-get-cache-path (symbol &optional proj-name inherit)
(unless proj-name
(setq proj-name mk-proj-name))
@@ -1488,13 +1498,20 @@ See also `mk-proj-config-save-section', `mk-proj-config-save-section'"
((and (mk-proj-get-config-val 'parent proj-name)
(file-exists-p (or (mk-proj-get-config-val symbol (mk-proj-get-config-val 'parent proj-name))
- (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name)))))
+ (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name))))
+ (or (eq inherit 'copy)))
- (copy-file (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name))
- r)
+ (copy-file (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name) t) r)
- (t
- r)))))
+ ((and (mk-proj-get-config-val 'parent proj-name)
+ (file-exists-p (or (mk-proj-get-config-val symbol (mk-proj-get-config-val 'parent proj-name))
+ (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name))))
+ (eq inherit t))
+ (or (mk-proj-get-config-val symbol (mk-proj-get-config-val 'parent proj-name))
+ (mk-proj-get-cache-path symbol (mk-proj-get-config-val 'parent proj-name))))
+ (t r)))))
+;;(mk-proj-get-cache-path 'file-list-cache mk-proj-name t)
(defun mk-proj-ancestry (&optional proj-name)
(let* ((current (or proj-name

0 comments on commit bc2d1b9

Please sign in to comment.