From: Dmitry Gutov Date: Mon, 24 Feb 2020 23:03:28 +0000 (+0200) Subject: vc-dir-ignore: More accurately choose base directory X-Git-Tag: emacs-27.0.90~20 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ec6eb1065;p=emacs.git vc-dir-ignore: More accurately choose base directory * lisp/vc/vc-dir.el: (vc-dir-ignore): Use it (bug#37189). * lisp/vc/vc.el: (vc--ignore-base-dir): Extract from vc-ignore. --- diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index e5c5e16a17a..38b4937e854 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -879,9 +879,10 @@ If a prefix argument is given, ignore all marked files." (vc-ignore (vc-dir-fileinfo->name filearg)) t)) vc-ewoc) - (vc-ignore - (file-relative-name (vc-dir-current-file)) - default-directory))) + (let ((rel-dir (vc--ignore-base-dir))) + (vc-ignore + (file-relative-name (vc-dir-current-file) rel-dir) + rel-dir)))) (defun vc-dir-current-file () (let ((node (ewoc-locate vc-ewoc))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 53491dd1b04..fe666413168 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1406,14 +1406,7 @@ When called interactively, prompt for a FILE to ignore, unless a prefix argument is given, in which case prompt for a file FILE to remove from the list of ignored files." (interactive - (let* ((backend (vc-responsible-backend default-directory)) - (rel-dir - (condition-case nil - (file-name-directory - (vc-call-backend backend 'find-ignore-file - default-directory)) - (vc-not-supported - default-directory))) + (let* ((rel-dir (vc--ignore-base-dir)) (file (read-file-name "File to ignore: "))) (when (and (file-name-absolute-p file) (file-in-directory-p file rel-dir)) @@ -1426,6 +1419,15 @@ remove from the list of ignored files." (error "Unknown backend")))) (vc-call-backend backend 'ignore file directory remove))) +(defun vc--ignore-base-dir () + (let ((backend (vc-responsible-backend default-directory))) + (condition-case nil + (file-name-directory + (vc-call-backend backend 'find-ignore-file + default-directory)) + (vc-not-supported + default-directory)))) + (defun vc-default-ignore (backend file &optional directory remove) "Ignore FILE under DIRECTORY (default is `default-directory'). FILE is a wildcard specification relative to DIRECTORY.