]> code.delx.au - gnu-emacs/commitdiff
Rename project-directories to project-roots
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 31 Jul 2015 02:37:28 +0000 (05:37 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 31 Jul 2015 02:53:14 +0000 (05:53 +0300)
* 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
lisp/progmodes/elisp-mode.el
lisp/progmodes/project.el
lisp/progmodes/xref.el

index 9e92fc7b4af11aa3079433466a5efe64e804ce41..3b06cf792d28922bb4bb3855965f0e07d88fc52c 100644 (file)
@@ -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)
 
index b7ae3c756deedc0dcb6b9993dc84e011f3c4cb47..cf34e1a2d473c0a6b62a886416bc089bb09ab6a8 100644 (file)
@@ -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
index 44a15dc591729f26808ff984dd64d86aae2e8f9b..27354598f8dcee62dfb42243ea6859fc82359820 100644 (file)
@@ -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
index 9d0dd77743f0c62004ca21f42a368193e1389a3b..9764bc78b1ace68141655d467bf1504a58134b13 100644 (file)
@@ -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)