From cecf3f6e9b42fbd074f83deedfb184a606e6b25d Mon Sep 17 00:00:00 2001 From: Aleksandar Simic Date: Sat, 5 May 2012 20:53:21 +0100 Subject: [PATCH 1/3] 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. --- egg.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/egg.el b/egg.el index 81c6e7c..c11b134 100644 --- a/egg.el +++ b/egg.el @@ -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"))) From 2fc98314144fdda6a69d20d504bb6f8f617c21f2 Mon Sep 17 00:00:00 2001 From: Aleksandar Simic Date: Sun, 6 May 2012 17:53:28 +0100 Subject: [PATCH 2/3] Made staging of multiple files more robust Previously via egg-status-buffer-stage-untracked-file you'd be able to stage multiple files from a selected area, which would contain their names. But if for example the following files where listed: aabc.txt xyz.txt and you selected text from 'b' in the first line to 'z' in the second line, the file names passed to git-add(1) would be: 'bc.txt' & 'xy'. Now, this is no longer the case, the whole lines would be selected and the area processed, so that 'aabc.txt' & 'xyz.txt' would be passed to git-add(1). --- egg.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/egg.el b/egg.el index c11b134..ea58cc1 100644 --- a/egg.el +++ b/egg.el @@ -2523,13 +2523,23 @@ untracked files" (mapc #'(lambda (file) (egg-sync-0 "add" file) (setq files (concat files file " "))) - (split-string - (buffer-substring-no-properties (point) (mark)) "\n" t)) + (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) - (message "new files added: %s" files)) + (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)))) + (let ((file (ffap-file-at-point))) (when (egg-sync-do-file file egg-git-command nil nil (list "add" "--" file)) (message "new file %s added" file))))) From ee191ad4bf5db2be08a7b8d1e6705e41f97a9fea Mon Sep 17 00:00:00 2001 From: Aleksandar Simic Date: Mon, 7 May 2012 07:35:27 +0100 Subject: [PATCH 3/3] Reverting the way single untracked files are staged This is due to change 0c6a7ffb, where ffap-file-at-point was intentionally replaced by looking for a filename between two points. This ensures that filenames with spaces can be acted on. --- egg.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/egg.el b/egg.el index ea58cc1..39c5a44 100644 --- a/egg.el +++ b/egg.el @@ -2539,7 +2539,8 @@ untracked files" (unless (string= files "") (message "new files added: %s" files))) ;; act only on single files - (let ((file (ffap-file-at-point))) + (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)))))