1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Dmitry Gutov 2015-08-10 04:04:57 +03:00
parent 6a45e72052
commit 6f9b233448
2 changed files with 38 additions and 8 deletions

View file

@ -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

View file

@ -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 ")