summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/maintaining.texi6
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/vc/vc-dir.el18
3 files changed, 29 insertions, 0 deletions
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index cca8441daa5..3ddea0ae588 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1316,6 +1316,12 @@ point is on a directory entry, mark all files in that directory tree
(@code{vc-dir-mark-all-files}). With a prefix argument, mark all
listed files and directories.
+@findex vc-dir-mark-by-regexp
+@item %
+You can use this command to mark files by regexp
+(@code{vc-dir-mark-by-regexp}). If given a prefix, unmark files
+instead.
+
@item G
Add the file under point to the list of files that the VC should
ignore (@code{vc-dir-ignore}). For instance, if the VC is Git, it
diff --git a/etc/NEWS b/etc/NEWS
index 9e985de0b39..68c7490e56c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1009,6 +1009,11 @@ info node. This command only works for the Emacs and Emacs Lisp manuals.
** vc
++++
+*** New command '%' ('vc-dir-mark-by-regexp').
+This command marks files based on a regexp. If given a prefix
+argument, unmark instead.
+
---
*** 'C-x v v' on an unregistered file will now use the most specific backend.
Previously, if you had an SVN-covered "~/" directory, and a Git-covered
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 1545763a3a1..9335da10065 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -325,6 +325,7 @@ See `run-hooks'."
(define-key map "U" #'vc-dir-unmark-all-files)
(define-key map "\C-?" #'vc-dir-unmark-file-up)
(define-key map "\M-\C-?" #'vc-dir-unmark-all-files)
+ (define-key map "%" #'vc-dir-mark-by-regexp)
;; Movement.
(define-key map "n" #'vc-dir-next-line)
(define-key map " " #'vc-dir-next-line)
@@ -750,6 +751,23 @@ share the same state."
(vc-dir-mark-file crt)))
(setq crt (ewoc-next vc-ewoc crt))))))))
+(defun vc-dir-mark-by-regexp (regexp &optional unmark)
+ "Mark all files that match REGEXP.
+If UNMARK (interactively, the prefix), unmark instead."
+ (interactive "sMark files matching: \nP")
+ (ewoc-map
+ (lambda (filearg)
+ (when (and (not (vc-dir-fileinfo->directory filearg))
+ (eq (not unmark)
+ (not (vc-dir-fileinfo->marked filearg)))
+ ;; We don't want to match on the part of the file
+ ;; that's above the current directory.
+ (string-match-p regexp (file-relative-name
+ (vc-dir-fileinfo->name filearg))))
+ (setf (vc-dir-fileinfo->marked filearg) (not unmark))
+ t))
+ vc-ewoc))
+
(defun vc-dir-mark-files (mark-files)
"Mark files specified by file names in the argument MARK-FILES.
MARK-FILES should be a list of absolute filenames."