branch: master commit f0d93cfcb3bdb6f14c39e0c3cd1a764f9dcd3e69 Author: Alex Bennée <alex.ben...@linaro.org> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel-compile): counsel-compile-get-filtered-history Add some commentary and use file-in-directory-p instead of treating paths and regexes. --- counsel.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/counsel.el b/counsel.el index 2d54e07..75b670d 100644 --- a/counsel.el +++ b/counsel.el @@ -5243,7 +5243,10 @@ subdirectories that builds may be invoked in." s)) (and blddir (counsel--get-build-subdirs blddir))))) -;; No easy way to make directory local, would buffer local make more sense? +;; This is a workaround for the fact there is no concept of "project" +;; local variables (as opposed to for example buffer-local). So we +;; store all our history in a global list filter out the results we +;; don't want. (defun counsel-compile-get-filtered-history (&optional dir) "Return a compile history relevant to current project." (let ((root (or dir (counsel--compile-root))) @@ -5251,9 +5254,8 @@ subdirectories that builds may be invoked in." (dolist (item counsel-compile-history) (let ((srcdir (get-text-property 0 'srcdir item)) (blddir (get-text-property 0 'blddir item))) - ;; FIXME: File names are not regexps! - (when (or (and srcdir (string-match-p srcdir root)) - (and blddir (string-match-p blddir root))) + (when (or (and srcdir (file-in-directory-p srcdir root)) + (and blddir (file-in-directory-p blddir root))) (push item history)))) history))