* [PATCH] Teach git.el to mark/unmark files by regexp
@ 2008-08-27 3:24 David Christensen
2008-08-30 18:41 ` Alexandre Julliard
0 siblings, 1 reply; 5+ messages in thread
From: David Christensen @ 2008-08-27 3:24 UTC (permalink / raw
To: git; +Cc: David Christensen
Adds the functions git-mark-regexp and git-unmark-regexp to git.el.
Creates a mark-map keymap to support dired-like behavior for
marking/unmarking via regexp. Also adds these functions to the
menubar.
Signed-off-by: David Christensen <david@endpoint.com>
---
contrib/emacs/git.el | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index c1cf1cb..279610f 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -944,6 +944,27 @@ Return the list of files that haven't been handled."
; move back to goal column after invalidate
(when goal-column (move-to-column goal-column)))
+(defun git-mark-regexp (re)
+ "Mark all files which match a provided regexp."
+ (interactive "sMark files matching regular expression: ")
+ (unless git-status (error "Not in git-status buffer."))
+ (ewoc-map (lambda (info) (unless (git-fileinfo->marked info)
+ (when (string-match re (git-fileinfo->name info))
+ (setf (git-fileinfo->marked info) t)))) git-status)
+ ; move back to goal column after invalidate
+ (when goal-column (move-to-column goal-column)))
+
+(defun git-unmark-regexp (re)
+ "Unmark all files which match a provided regexp."
+ (interactive "sUnmark files matching regular expression: ")
+ (unless git-status (error "Not in git-status buffer."))
+ (ewoc-map (lambda (info) (when (git-fileinfo->marked info)
+ (when (string-match re (git-fileinfo->name info))
+ (setf (git-fileinfo->marked info) nil)) t)) git-status)
+ ; move back to goal column after invalidate
+ (when goal-column (move-to-column goal-column)))
+
+
(defun git-toggle-all-marks ()
"Toggle all file marks."
(interactive)
@@ -1420,9 +1441,11 @@ amended version of it."
(let ((map (make-keymap))
(commit-map (make-sparse-keymap))
(diff-map (make-sparse-keymap))
- (toggle-map (make-sparse-keymap)))
+ (toggle-map (make-sparse-keymap))
+ (mark-map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "?" 'git-help)
+ (define-key map "*" mark-map)
(define-key map "h" 'git-help)
(define-key map " " 'git-next-file)
(define-key map "a" 'git-add-file)
@@ -1469,6 +1492,9 @@ amended version of it."
(define-key toggle-map "i" 'git-toggle-show-ignored)
(define-key toggle-map "k" 'git-toggle-show-unknown)
(define-key toggle-map "m" 'git-toggle-all-marks)
+ ; the mark submap
+ (define-key mark-map "%" 'git-mark-regexp)
+ (define-key mark-map "\C-?" 'git-unmark-regexp)
(setq git-status-mode-map map))
(easy-menu-define git-menu git-status-mode-map
"Git Menu"
@@ -1499,8 +1525,10 @@ amended version of it."
"--------"
["Mark" git-mark-file t]
["Mark All" git-mark-all t]
+ ["Mark Regexp" git-mark-regexp t]
["Unmark" git-unmark-file t]
["Unmark All" git-unmark-all t]
+ ["Unmark Regexp" git-unmark-regexp t]
["Toggle All Marks" git-toggle-all-marks t]
["Hide Handled Files" git-remove-handled t]
"--------"
--
1.6.0.1.90.g27a6e.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Teach git.el to mark/unmark files by regexp
2008-08-27 3:24 [PATCH] Teach git.el to mark/unmark files by regexp David Christensen
@ 2008-08-30 18:41 ` Alexandre Julliard
2008-08-30 19:02 ` David Christensen
0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Julliard @ 2008-08-30 18:41 UTC (permalink / raw
To: David Christensen; +Cc: git
David Christensen <david@endpoint.com> writes:
> Adds the functions git-mark-regexp and git-unmark-regexp to git.el.
> Creates a mark-map keymap to support dired-like behavior for
> marking/unmarking via regexp. Also adds these functions to the
> menubar.
I think that emulating dired behavior is a good idea, but you should go
all the way and make it fully compatible, unmark is supposed to be "* %"
with a prefix arg, and "* DEL" should be git-unmark-file-up.
--
Alexandre Julliard
julliard@winehq.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Teach git.el to mark/unmark files by regexp
2008-08-30 18:41 ` Alexandre Julliard
@ 2008-08-30 19:02 ` David Christensen
2008-09-12 4:22 ` [PATCH v2] " David Christensen
0 siblings, 1 reply; 5+ messages in thread
From: David Christensen @ 2008-08-30 19:02 UTC (permalink / raw
To: Alexandre Julliard; +Cc: git
>> Adds the functions git-mark-regexp and git-unmark-regexp to git.el.
>> Creates a mark-map keymap to support dired-like behavior for
>> marking/unmarking via regexp. Also adds these functions to the
>> menubar.
>
> I think that emulating dired behavior is a good idea, but you should
> go
> all the way and make it fully compatible, unmark is supposed to be
> "* %"
> with a prefix arg, and "* DEL" should be git-unmark-file-up.
Sounds good; I'll review other mark-related dired bindings and see if
there are other correspondences we can make, and then resubmit a patch.
Regards,
David
--
David Christensen
End Point Corporation
david@endpoint.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] Teach git.el to mark/unmark files by regexp
2008-08-30 19:02 ` David Christensen
@ 2008-09-12 4:22 ` David Christensen
2008-09-12 4:22 ` [PATCH] " David Christensen
0 siblings, 1 reply; 5+ messages in thread
From: David Christensen @ 2008-09-12 4:22 UTC (permalink / raw
To: git; +Cc: julliard, gister
Teaches git-mark-regexp to respect a prefix argument as an indication
to unmark files. Also adds other dired-like key bindings.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Teach git.el to mark/unmark files by regexp
2008-09-12 4:22 ` [PATCH v2] " David Christensen
@ 2008-09-12 4:22 ` David Christensen
0 siblings, 0 replies; 5+ messages in thread
From: David Christensen @ 2008-09-12 4:22 UTC (permalink / raw
To: git; +Cc: julliard, gister, David Christensen
Adds the functions git-mark-regexp and git-unmark-regexp to git.el.
Creates a mark-map keymap to support dired-like behavior for
marking/unmarking via regexp. Also adds these functions to the
menubar.
Signed-off-by: David Christensen <david@endpoint.com>
---
contrib/emacs/git.el | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 580652c..a982fbe 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -950,14 +950,18 @@ Return the list of files that haven't been handled."
(when goal-column (move-to-column goal-column)))
(defun git-mark-regexp (re)
- "Mark all files which match a provided regexp."
- (interactive "sMark files matching regular expression: ")
+ "Mark all files which match a provided regexp. With prefix argument, unmark files which match."
+ (interactive
+ (list
+ (read-from-minibuffer (if current-prefix-arg "Unmark files matching regular expression: " "Mark files matching regular expression: "))))
(unless git-status (error "Not in git-status buffer."))
- (ewoc-map (lambda (info) (unless (git-fileinfo->marked info)
- (when (string-match re (git-fileinfo->name info))
- (setf (git-fileinfo->marked info) t)))) git-status)
- ; move back to goal column after invalidate
- (when goal-column (move-to-column goal-column)))
+ (if current-prefix-arg
+ (git-unmark-regexp re)
+ (ewoc-map (lambda (info) (unless (git-fileinfo->marked info)
+ (when (string-match re (git-fileinfo->name info))
+ (setf (git-fileinfo->marked info) t)))) git-status)
+ ; move back to goal column after invalidate
+ (when goal-column (move-to-column goal-column))))
(defun git-unmark-regexp (re)
"Unmark all files which match a provided regexp."
@@ -1504,7 +1508,12 @@ amended version of it."
(define-key toggle-map "m" 'git-toggle-all-marks)
; the mark submap
(define-key mark-map "%" 'git-mark-regexp)
- (define-key mark-map "\C-?" 'git-unmark-regexp)
+ (define-key mark-map "m" 'git-mark-file)
+ (define-key mark-map "u" 'git-unmark-file)
+ (define-key mark-map "t" 'git-toggle-all-marks)
+ (define-key mark-map "!" 'git-unmark-all)
+ (define-key mark-map "?" 'git-unmark-all)
+ (define-key mark-map "\C-?" 'git-unmark-file-up)
(setq git-status-mode-map map))
(easy-menu-define git-menu git-status-mode-map
"Git Menu"
--
1.6.0.1.90.g27a6e.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-09-12 4:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27 3:24 [PATCH] Teach git.el to mark/unmark files by regexp David Christensen
2008-08-30 18:41 ` Alexandre Julliard
2008-08-30 19:02 ` David Christensen
2008-09-12 4:22 ` [PATCH v2] " David Christensen
2008-09-12 4:22 ` [PATCH] " David Christensen
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).