emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 6f9b233 1/2: Add project-vc-search-path and project


From: Dmitry Gutov
Subject: [Emacs-diffs] master 6f9b233 1/2: Add project-vc-search-path and project-vc-ignores
Date: Mon, 10 Aug 2015 01:30:54 +0000

branch: master
commit 6f9b233448448adaf894b1586d4508c3d8573aba
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Add project-vc-search-path and project-vc-ignores
    
    * lisp/progmodes/project.el (project-vc): New group.
    (project-vc-search-path, project-vc-ignores): New variables.
    (project--value-in-dir): Utility function.
    (project-search-path, project-ignores): Use them.
    
    * lisp/progmodes/xref.el (xref--rgrep-command): Only replace `./'
    at bos.  Don't add extra `/'.  Don't prepend with `*' if replaced.
---
 lisp/progmodes/project.el |   38 ++++++++++++++++++++++++++++++++++----
 lisp/progmodes/xref.el    |    8 ++++----
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 16578f1..186840a 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -97,6 +97,21 @@ an element of `project-search-path'."
     vc-directory-exclusion-list)
    grep-find-ignored-files))
 
+(defgroup project-vc nil
+  "Project implementation using the VC package."
+  :group 'tools)
+
+(defcustom project-vc-search-path nil
+  "List ot directories to include in `project-search-path'.
+The file names can be absolute, or relative to the project root."
+  :type '(repeat file)
+  :safe 'listp)
+
+(defcustom project-vc-ignores nil
+  "List ot patterns to include in `project-ignores'."
+  :type '(repeat string)
+  :safe 'listp)
+
 (defun project-try-vc (dir)
   (let* ((backend (ignore-errors (vc-responsible-backend dir)))
          (root (and backend (ignore-errors
@@ -106,10 +121,18 @@ an element of `project-search-path'."
 (cl-defmethod project-roots ((project (head vc)))
   (list (cdr project)))
 
+(cl-defmethod project-search-path ((project (head vc)))
+  (append
+   (let ((root (cdr project)))
+     (mapcar
+      (lambda (dir) (expand-file-name dir root))
+      (project--value-in-dir 'project-vc-search-path root)))
+   (cl-call-next-method)))
+
 (cl-defmethod project-ignores ((project (head vc)) dir)
-  (nconc
-   (let* ((root (cdr project))
+  (let* ((root (cdr project))
           backend)
+    (append
      (when (file-equal-p dir root)
        (setq backend (vc-responsible-backend root))
        (mapcar
@@ -117,8 +140,9 @@ an element of `project-search-path'."
           (if (string-match "\\`/" entry)
               (replace-match "./" t t entry)
             entry))
-        (vc-call-backend backend 'ignore-completion-table root))))
-   (cl-call-next-method)))
+        (vc-call-backend backend 'ignore-completion-table root)))
+     (project--value-in-dir 'project-vc-ignores root)
+     (cl-call-next-method))))
 
 (defun project-ask-user (dir)
   (cons 'user (read-directory-name "Project root: " dir nil t)))
@@ -142,5 +166,11 @@ an element of `project-search-path'."
         (setq ref (cdr ref))))
     (cl-delete-if-not #'file-exists-p dirs)))
 
+(defun project--value-in-dir (var dir)
+  (with-temp-buffer
+    (setq default-directory dir)
+    (hack-dir-local-variables-non-file-buffer)
+    (symbol-value var)))
+
 (provide 'project)
 ;;; project.el ends here
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index c37a4aa..4189977 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -934,12 +934,12 @@ IGNORES is a list of glob patterns."
     " -path "
     (mapconcat
      (lambda (ignore)
-       (when (string-match "\\(\\.\\)/" ignore)
-         (setq ignore (replace-match dir t t ignore 1)))
        (when (string-match-p "/\\'" ignore)
          (setq ignore (concat ignore "*")))
-       (unless (string-prefix-p "*" ignore)
-         (setq ignore (concat "*/" ignore)))
+       (if (string-match "\\`\\./" ignore)
+           (setq ignore (replace-match dir t t ignore))
+         (unless (string-prefix-p "*" ignore)
+           (setq ignore (concat "*/" ignore))))
        (shell-quote-argument ignore))
      ignores
      " -o -path ")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]