emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 6a79a16 1/2: Rename project-directories to project-


From: Dmitry Gutov
Subject: [Emacs-diffs] master 6a79a16 1/2: Rename project-directories to project-roots
Date: Fri, 31 Jul 2015 02:55:11 +0000

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

    Rename project-directories to project-roots
    
    * lisp/progmodes/project.el (project-search-path-function)
    (project-search-path): Update the docstring.
    (project-directories): Rename to `project-roots', update all
    callers and implementations accordingly.
    (project-root): Remove.
    
    * lisp/progmodes/xref.el (xref-find-regexp): Use * instead of *.*
    as the default file mask.
---
 lisp/cedet/ede.el            |    4 +-
 lisp/progmodes/elisp-mode.el |    1 +
 lisp/progmodes/project.el    |   74 +++++++++++++++++++----------------------
 lisp/progmodes/xref.el       |   10 +++--
 4 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/lisp/cedet/ede.el b/lisp/cedet/ede.el
index 9e92fc7..3b06cf7 100644
--- a/lisp/cedet/ede.el
+++ b/lisp/cedet/ede.el
@@ -1528,8 +1528,8 @@ It does not apply the value to buffers."
     (when project-dir
       (ede-directory-get-open-project project-dir 'ROOT))))
 
-(cl-defmethod project-root ((project ede-project))
-  (ede-project-root-directory project))
+(cl-defmethod project-roots ((project ede-project))
+  (list (ede-project-root-directory project)))
 
 (add-hook 'project-find-functions #'project-try-ede)
 
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index b7ae3c7..cf34e1a 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -655,6 +655,7 @@ 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 44a15dc..2735459 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -37,16 +37,16 @@ that it is not applicable, or a project instance.")
 (declare-function etags-search-path "etags" ())
 
 (defvar project-search-path-function #'etags-search-path
-  "Function that returns a list of source directories.
+  "Function that returns a list of source root directories.
 
-The directories in which we can look for the declarations or
-other references to the symbols used in the current buffer.
-Depending on the language, it should include the headers search
-path, load path, class path, and so on.
+The directories in which we can recursively look for the
+declarations or other references to the symbols used in the
+current buffer.  Depending on the language, it should include the
+headers search path, load path, class path, or so on.
 
-The directory names should be absolute.  Normally set by the
-major mode.  Used in the default implementation of
-`project-search-path'.")
+The directory names should be absolute.  This variable is
+normally set by the major mode.  Used in the default
+implementation of `project-search-path'.")
 
 ;;;###autoload
 (defun project-current (&optional dir)
@@ -54,35 +54,29 @@ major mode.  Used in the default implementation of
   (unless dir (setq dir default-directory))
   (run-hook-with-args-until-success 'project-find-functions dir))
 
-(cl-defgeneric project-root (project)
-  "Return the root directory of the current project.
-The directory name should be absolute.")
-
+;; FIXME: Add MODE argument, like in `ede-source-paths'?
 (cl-defgeneric project-search-path (project)
-  "Return the list of source directories.
-Including any where source (or header, etc) files used by the
-current project may be found, inside or outside of the project
-tree.  The directory names should be absolute.
-
-A specialized implementation should use the value
-`project-search-path-function', or, better yet, call and combine
-the results from the functions that this value is set to by all
-major modes used in the project.  Alternatively, it can return a
-user-configurable value."
-  (project--prune-directories
-   (nconc (funcall project-search-path-function)
-          ;; Include these, because we don't know any better.
-          ;; But a specialized implementation may include only some of
-          ;; the project's subdirectories, if there are no source
-          ;; files at the top level.
-          (project-directories project))))
-
-(cl-defgeneric project-directories (project)
-  "Return the list of directories related to the current project.
+  "Return the list of source root directories.
+Any directory roots where source (or header, etc) files used by
+the current project may be found, inside or outside of the
+current project tree(s).  The directory names should be absolute.
+
+Unless it really knows better, a specialized implementation
+should take into account the value returned by
+`project-search-path-function' and call
+`project-prune-directories' on the result."
+  (project-prune-directories
+   (append
+    ;; We don't know the project layout, like where the sources are,
+    ;; so we simply include the roots.
+    (project-roots project)
+    (funcall project-search-path-function))))
+
+(cl-defgeneric project-roots (project)
+  "Return the list of directory roots related to the current project.
 It should include the current project root, as well as the roots
-of any currently open related projects, if they're meant to be
-edited together.  The directory names should be absolute."
-  (list (project-root project)))
+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.
@@ -103,8 +97,8 @@ end it with `/'."
                               (vc-call-backend backend 'root dir)))))
     (and root (cons 'vc root))))
 
-(cl-defmethod project-root ((project (head vc)))
-  (cdr project))
+(cl-defmethod project-roots ((project (head vc)))
+  (list (cdr project)))
 
 (cl-defmethod project-ignores ((project (head vc)))
   (nconc
@@ -121,10 +115,10 @@ end it with `/'."
 (defun project-ask-user (dir)
   (cons 'user (read-directory-name "Project root: " dir nil t)))
 
-(cl-defmethod project-root ((project (head user)))
-  (cdr project))
+(cl-defmethod project-roots ((project (head user)))
+  (list (cdr project)))
 
-(defun project--prune-directories (dirs)
+(defun project-prune-directories (dirs)
   "Returns a copy of DIRS sorted, without subdirectories or non-existing ones."
   (let* ((dirs (sort
                 (mapcar
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9d0dd77..9764bc7 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -767,6 +767,8 @@ With prefix argument, prompt for the identifier."
   (interactive (list (xref--read-identifier "Find references of: ")))
   (xref--show-xrefs identifier 'references identifier nil))
 
+;; TODO: Rename and move to project-find-regexp, as soon as idiomatic
+;; usage of xref from other packages has stabilized.
 ;;;###autoload
 (defun xref-find-regexp (regexp)
   "Find all matches for REGEXP.
@@ -777,13 +779,13 @@ to search in, and the file name pattern to search for."
   (let* ((proj (project-current))
          (files (if current-prefix-arg
                     (grep-read-files regexp)
-                  "*.*"))
+                  "*"))
          (dirs (if current-prefix-arg
                    (list (read-directory-name "Base directory: "
                                               nil default-directory t))
-                 (project--prune-directories
-                  (nconc
-                   (project-directories proj)
+                 (project-prune-directories
+                  (append
+                   (project-roots proj)
                    (project-search-path proj)))))
          (xref-find-function
           (lambda (_kind regexp)



reply via email to

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