From: Dmitry Gutov Date: Mon, 10 Aug 2015 01:04:57 +0000 (+0300) Subject: Add project-vc-search-path and project-vc-ignores X-Git-Tag: emacs-25.0.90~1373^2~72 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6f9b233448448adaf894b1586d4508c3d8573aba;p=emacs.git 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. --- diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 16578f11374..186840ae29b 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 c37a4aafe97..418997796d6 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 ")