Permalink
Browse files

Improvement on egg-status-buffer-stage-untracked-file

Now egg-status-buffer-stage-untracked-file function can now stage files
in batches, from a region selected area, as opposed to adding them one
by one.
  • Loading branch information...
1 parent 8efd9c6 commit cecf3f6e9b42fbd074f83deedfb184a606e6b25d @dotemacs committed May 5, 2012
Showing with 20 additions and 4 deletions.
  1. +20 −4 egg.el
View
@@ -2512,11 +2512,27 @@ rebase session."
(egg-buffer-cmd-refresh)))
(defun egg-status-buffer-stage-untracked-file ()
+ "add untracked file(s) to the repository
+
+acts on a single file or on a region which contains the names of
+untracked files"
(interactive)
- (let ((file (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
- (when (egg-sync-do-file file egg-git-command nil nil
- (list "add" "--" file))
- (message "new file %s added" file))))
+ ;; act on multiple files
+ (if mark-active
+ (let ((files ""))
+ (mapc #'(lambda (file)
+ (egg-sync-0 "add" file)
+ (setq files (concat files file " ")))
+ (split-string
+ (buffer-substring-no-properties (point) (mark)) "\n" t))
+ (deactivate-mark)
+ (message "new files added: %s" files))
+ ;; act only on single files
+ (let ((file (buffer-substring-no-properties
+ (line-beginning-position) (line-end-position))))
+ (when (egg-sync-do-file file egg-git-command nil nil
+ (list "add" "--" file))
+ (message "new file %s added" file)))))
(defconst egg-untracked-file-map
(let ((map (make-sparse-keymap "Egg:UntrackedFile")))

0 comments on commit cecf3f6

Please sign in to comment.