emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 543bb9b: Add a second argument to project-ignores


From: Dmitry Gutov
Subject: [Emacs-diffs] master 543bb9b: Add a second argument to project-ignores
Date: Sat, 01 Aug 2015 22:31:27 +0000

branch: master
commit 543bb9bc2023fafdadf697e23484214daac95dee
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Add a second argument to project-ignores
    
    * lisp/progmodes/project.el (project-ignores): Add a second
    argument DIR.
    
    * lisp/progmodes/project.el (project-ignores): Only include the VC
    ignores if DIR is the VC root.
    
    * lisp/progmodes/xref.el (xref-find-regexp): Update accordingly.
---
 lisp/progmodes/elisp-mode.el |    1 -
 lisp/progmodes/project.el    |   28 ++++++++++++++++------------
 lisp/progmodes/xref.el       |    3 ++-
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cf34e1a..b7ae3c7 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -655,7 +655,6 @@ It can be quoted, or be inside a quoted form."
 
 (declare-function project-search-path "project")
 (declare-function project-current "project")
-(declare-function project-prune-directories "project")
 
 (defun elisp--xref-find-references (symbol)
   (cl-mapcan
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2735459..d849f93 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -78,10 +78,12 @@ It should include the current project root, as well as the 
roots
 of any other currently open projects, if they're meant to be
 edited together.  The directory names should be absolute.")
 
-(cl-defgeneric project-ignores (_project)
-  "Return the list of glob patterns that match ignored files.
+(cl-defgeneric project-ignores (_project _dir)
+  "Return the list of glob patterns to ignore inside DIR.
+Patterns can match both regular files and directories.
 To root an entry, start it with `./'.  To match directories only,
-end it with `/'."
+end it with `/'.  DIR must be either one of `project-roots', or
+an element of `project-search-path'."
   (require 'grep)
   (defvar grep-find-ignored-files)
   (nconc
@@ -100,16 +102,18 @@ end it with `/'."
 (cl-defmethod project-roots ((project (head vc)))
   (list (cdr project)))
 
-(cl-defmethod project-ignores ((project (head vc)))
+(cl-defmethod project-ignores ((project (head vc)) dir)
   (nconc
-   (let* ((dir (cdr project))
-          (backend (vc-responsible-backend dir)))
-     (mapcar
-      (lambda (entry)
-        (if (string-match "\\`/" entry)
-            (replace-match "./" t t entry)
-          entry))
-      (vc-call-backend backend 'ignore-completion-table dir)))
+   (let* ((root (cdr project))
+          backend)
+     (when (file-equal-p dir root)
+       (setq backend (vc-responsible-backend root))
+       (mapcar
+        (lambda (entry)
+          (if (string-match "\\`/" entry)
+              (replace-match "./" t t entry)
+            entry))
+        (vc-call-backend backend 'ignore-completion-table root))))
    (cl-call-next-method)))
 
 (defun project-ask-user (dir)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9764bc7..27e56f2 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -791,7 +791,8 @@ to search in, and the file name pattern to search for."
           (lambda (_kind regexp)
             (cl-mapcan
              (lambda (dir)
-               (xref-collect-matches regexp files dir (project-ignores proj)))
+               (xref-collect-matches regexp files dir
+                                     (project-ignores proj dir)))
              dirs))))
     (xref--show-xrefs regexp 'matches regexp nil)))
 



reply via email to

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