1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Add new command 'vc-dir-mark-by-regexp'

* doc/emacs/maintaining.texi (VC Directory Commands): Document it.
* lisp/vc/vc-dir.el (vc-dir-mode-map): Bind it to `%'.
(vc-dir-mark-by-regexp): New command (bug#16460).
This commit is contained in:
Lars Ingebrigtsen 2022-05-11 14:59:17 +02:00
parent 5079f42446
commit d373daf568
3 changed files with 29 additions and 0 deletions

View file

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

View file

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

View file

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