summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/vc/vc-bzr.el15
-rw-r--r--lisp/vc/vc-git.el16
-rw-r--r--lisp/vc/vc-hg.el16
-rw-r--r--lisp/vc/vc-svn.el3
-rw-r--r--lisp/vc/vc.el73
6 files changed, 55 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5dfca6b8e2f..9292732dc4c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2013-09-04 Xue Fuqiao <xfq.free@gmail.com>
+
+ * vc/vc.el (vc-ignore): Rewrite.
+ (vc-default-ignore): New function.
+ (vc-default-ignore-completion-table): Use find-ignore-file.
+
+ * vc/vc-bzr.el (vc-bzr-ignore, vc-bzr-ignore-completion-table):
+ * vc/vc-git.el (vc-git-ignore, vc-git-ignore-completion-table):
+ * vc/vc-hg.el (vc-hg-ignore, vc-hg-ignore-completion-table):
+ Remove. Most code moved to vc.el.
+
2013-08-04 Xue Fuqiao <xfq.free@gmail.com>
* vc/vc.el (vc-ignore): Rewrite.
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index e59a7dc5214..0d95fbed8c2 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -651,21 +651,6 @@ REV non-nil gets an error."
(vc-bzr-command "cat" t 0 file "-r" rev)
(vc-bzr-command "cat" t 0 file))))
-(defun vc-bzr-ignore (file &optional directory remove)
- "Ignore FILE under Bazaar.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
- (if remove
- (if directory
- (vc--remove-regexp file (vc-bzr-find-ignore-file directory))
- (vc--remove-regexp file
- (vc-bzr-find-ignore-file default-directory)))
- (vc-bzr-command "ignore" t 0 file)))
-
-(defun vc-bzr-ignore-completion-table (file)
- "Return the list of ignored files."
- (vc--read-lines (vc-bzr-find-ignore-file file)))
-
(defun vc-bzr-find-ignore-file (file)
"Return the root directory of the repository of FILE."
(expand-file-name ".bzrignore"
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 472c42840af..07b7d15299f 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -680,22 +680,6 @@ It is based on `log-edit-mode', and has Git-specific extensions.")
nil
"cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname))))
-(defun vc-git-ignore (file &optional directory remove)
- "Ignore FILE under Git.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
- (let (gitignore)
- (if directory
- (setq gitignore (vc-git-find-ignore-file directory))
- (setq gitignore (vc-git-find-ignore-file default-directory)))
- (if remove
- (vc--remove-regexp file gitignore)
- (vc--add-line file gitignore))))
-
-(defun vc-git-ignore-completion-table (file)
- "Return the list of ignored files."
- (vc--read-lines (vc-git-find-ignore-file file)))
-
(defun vc-git-find-ignore-file (file)
"Return the root directory of the repository of FILE."
(expand-file-name ".gitignore"
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 68d98a60f98..211a0c131c9 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -459,22 +459,6 @@ REV is ignored."
(vc-hg-command buffer 0 file "cat" "-r" rev)
(vc-hg-command buffer 0 file "cat"))))
-(defun vc-hg-ignore (file &optional directory remove)
- "Ignore FILE under Mercurial.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
- (let (hgignore)
- (if directory
- (setq hgignore (vc-hg-find-ignore-file directory))
- (setq hgignore (vc-hg-find-ignore-file default-directory)))
- (if remove
- (vc--remove-regexp file hgignore)
- (vc--add-line file hgignore))))
-
-(defun vc-hg-ignore-completion-table (file)
- "Return the list of ignored files."
- (vc--read-lines (vc-hg-find-ignore-file file)))
-
(defun vc-hg-find-ignore-file (file)
"Return the root directory of the repository of FILE."
(expand-file-name ".hgignore"
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 0e020614fd2..38c3bd9970d 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -354,8 +354,7 @@ This is only possible if SVN is responsible for FILE's directory.")
(defun vc-svn-ignore (file &optional directory remove)
"Ignore FILE under Subversion.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
+FILE is a file wildcard, relative to the root directory of DIRECTORY."
(vc-svn-command t 0 file "propedit" "svn:ignore"))
(defun vc-svn-ignore-completion-table (file)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9757d4a43be..007bbe86f34 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -497,17 +497,19 @@
;; This function is used in `vc-stay-local-p' which backends can use
;; for their convenience.
;;
-;; - ignore (file &optional remove)
-;;
-;; Ignore FILE under the current VCS. When called interactively and
-;; with a prefix argument, remove an ignored file. When called from
-;; Lisp code, if REMOVE is non-nil, remove FILE from ignored files."
+;; - ignore (file &optional directory)
+;;
+;; Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+;; FILE is a file wildcard.
+;; When called interactively and with a prefix argument, remove FILE
+;; from ignored files.
+;; When called from Lisp code, if DIRECTORY is non-nil, the
+;; repository to use will be deduced by DIRECTORY.
;;
;; - ignore-completion-table
;;
-;; Return the completion table for files ignored by the current
-;; version control system, e.g., the entries in `.gitignore' and
-;; `.bzrignore'.
+;; Return the completion table for files ignored by the version
+;; control system in `default-directory'.
;;
;; - previous-revision (file rev)
;;
@@ -1342,33 +1344,44 @@ first backend that could register the file is used."
(let ((vc-handled-backends (list backend)))
(call-interactively 'vc-register)))
-(defun vc-ignore (file &optional directory remove)
+(defun vc-ignore (file &optional directory)
"Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+FILE is a file wildcard.
When called interactively and with a prefix argument, remove FILE
from ignored files.
When called from Lisp code, if DIRECTORY is non-nil, the
-repository to use will be deduced by DIRECTORY; if REMOVE is
-non-nil, remove FILE from ignored files."
+repository to use will be deduced by DIRECTORY."
(interactive
- (if (null current-prefix-arg)
- (list (read-file-name "The file to ignore: "))
- (list
- (completing-read
- "The file to remove: "
- (vc-call-backend
- (vc-backend default-directory)
- 'ignore-completion-table default-directory)))))
- (let (backend)
- (if directory
- (progn (setq backend (vc-backend default-directory))
- (vc-call-backend backend 'ignore file directory remove))
- (setq backend (vc-backend directory))
- (vc-call-backend backend 'ignore file default-directory remove))))
-
-(defun vc-default-ignore-completion-table (file)
- "Return the list of ignored files."
- ;; Unused lexical argument `file'
- nil)
+ (list (read-file-name "The file to ignore: ")
+ (completing-read
+ "The file to remove: "
+ (vc-call-backend
+ (vc-backend default-directory)
+ 'ignore-completion-table default-directory))))
+ (let* ((directory (or directory default-directory))
+ (backend (vc-backend default-directory))
+ (remove current-prefix-arg))
+ (vc-call-backend backend 'ignore file directory remove)))
+
+(defun vc-default-ignore (backend file &optional directory remove)
+ "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+FILE is a file wildcard, relative to the root directory of DIRECTORY.
+When called from Lisp code, if DIRECTORY is non-nil, the
+repository to use will be deduced by DIRECTORY; if REMOVE is
+non-nil, remove FILE from ignored files.
+Argument BACKEND is the backend you are using."
+ (let ((ignore
+ (vc-call-backend backend 'find-ignore-file (or directory default-directory)))
+ (pattern (file-relative-name
+ (expand-file-name file) (file-name-directory file))))
+ (if remove
+ (vc--remove-regexp pattern ignore)
+ (vc--add-line pattern ignore))))
+
+(defun vc-default-ignore-completion-table (backend file)
+ "Return the list of ignored files under BACKEND."
+ (vc--read-lines
+ (vc-call-backend backend 'find-ignore-file file)))
(defun vc--read-lines (file)
"Return a list of lines of FILE."