Skip to content
Browse files

Merge remote-tracking branch 'dotemacs/stage-multiple-untracked-files…

…' into local
  • Loading branch information...
2 parents 88fb583 + ee191ad commit bebf5863f5be2eed5a5d617f3b2add2c87b2a32f @yukio-goto yukio-goto committed Jun 12, 2012
Showing with 31 additions and 4 deletions.
  1. +31 −4 egg.el
View
35 egg.el
@@ -2512,11 +2512,38 @@ 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 " ")))
+ (progn
+ (if (< (point) (mark))
+ (progn
+ (goto-char (line-beginning-position))
+ (exchange-point-and-mark)
+ (goto-char (line-end-position)))
+ (progn
+ (goto-char (line-end-position))
+ (exchange-point-and-mark)
+ (goto-char (line-beginning-position))))
+ (split-string
+ (buffer-substring-no-properties (point) (mark)) "\n" t)))
+ (deactivate-mark)
+ (unless (string= files "")
+ (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 bebf586

Please sign in to comment.
Something went wrong with that request. Please try again.