From 1b31c106f841082822479085819bd44483ea9b14 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Thu, 6 May 2010 17:56:59 +0100 Subject: [PATCH 1/5] Added `magit-list-buffers'. --- magit.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/magit.el b/magit.el index a8c75c84..8ea62582 100644 --- a/magit.el +++ b/magit.el @@ -4045,6 +4045,14 @@ With prefix force the removal even it it hasn't been merged." ((diff) (magit-interactive-resolve (cadr info))))) +(defun magit-list-buffers () + "Returns a list of magit buffers." + (remove-if-not (lambda (b) + (save-excursion + (set-buffer b) + (eq major-mode 'magit-mode))) + (buffer-list))) + (provide 'magit) ;;; magit.el ends here From 0ca04f71bbb14a306b21a49f168dddbd1498344c Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Thu, 6 May 2010 17:57:08 +0100 Subject: [PATCH 2/5] Added `magit-list-projects. --- magit.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/magit.el b/magit.el index 8ea62582..615bbc99 100644 --- a/magit.el +++ b/magit.el @@ -4053,6 +4053,18 @@ With prefix force the removal even it it hasn't been merged." (eq major-mode 'magit-mode))) (buffer-list))) +(defun magit-list-projects () + "Returns a list of toplevel directories with a magit +representation." + (remove-duplicates + (mapcar (lambda (b) + (save-excursion + (set-buffer b) + (file-name-nondirectory + (directory-file-name default-directory)))) + (magit-list-buffers)) + :test 'string=)) + (provide 'magit) ;;; magit.el ends here From f2817e7c78185a315c478fd1609bcdc02d650005 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Thu, 6 May 2010 18:18:02 +0100 Subject: [PATCH 3/5] `magit-list-projects' returns full path. --- magit.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index 615bbc99..86841b33 100644 --- a/magit.el +++ b/magit.el @@ -4054,14 +4054,12 @@ With prefix force the removal even it it hasn't been merged." (buffer-list))) (defun magit-list-projects () - "Returns a list of toplevel directories with a magit -representation." + "Returns a list of directories with a magit representation." (remove-duplicates (mapcar (lambda (b) (save-excursion (set-buffer b) - (file-name-nondirectory - (directory-file-name default-directory)))) + (directory-file-name default-directory))) (magit-list-buffers)) :test 'string=)) From 326fff28230506e2935263e21f7641300700b8e5 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Thu, 6 May 2010 19:26:34 +0100 Subject: [PATCH 4/5] Replace cl functions. --- magit.el | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/magit.el b/magit.el index 86841b33..ea3ecafb 100644 --- a/magit.el +++ b/magit.el @@ -4047,21 +4047,33 @@ With prefix force the removal even it it hasn't been merged." (defun magit-list-buffers () "Returns a list of magit buffers." - (remove-if-not (lambda (b) - (save-excursion - (set-buffer b) - (eq major-mode 'magit-mode))) - (buffer-list))) + (delq nil (mapcar (lambda (b) + (save-excursion + (set-buffer b) + (when (eq major-mode 'magit-mode) + b))) + (buffer-list)))) + +(defun remove-dupes (list) + "Remove the duplicate items in a sorted list." + (let (tmp-list head) + (while list + (setq head (pop list)) + (unless (equal head (car list)) + (push head tmp-list))) + (reverse tmp-list))) (defun magit-list-projects () "Returns a list of directories with a magit representation." - (remove-duplicates - (mapcar (lambda (b) - (save-excursion - (set-buffer b) - (directory-file-name default-directory))) - (magit-list-buffers)) - :test 'string=)) + (remove-dupes + (sort + (mapcar (lambda (b) + (save-excursion + (set-buffer b) + (directory-file-name default-directory))) + (magit-list-buffers)) + 'string=))) + (provide 'magit) From effbbb3b1376c0ffdc5f849b7eb5b8ae53f6bd4f Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Thu, 6 May 2010 19:26:51 +0100 Subject: [PATCH 5/5] Added `magit-wl-pipe-to-am'. --- magit.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/magit.el b/magit.el index ea3ecafb..41553412 100644 --- a/magit.el +++ b/magit.el @@ -4074,6 +4074,17 @@ With prefix force the removal even it it hasn't been merged." (magit-list-buffers)) 'string=))) +(defun magit-wl-pipe-to-am () + "Ask the user for a project in which to apply (via am) the +current email in wl." + (interactive) + "Pipe a wanderlust message into git am." + (let* ((proj (funcall magit-completing-read + "Apply to project: " + (magit-list-projects) + nil t nil nil))) + (wl-summary-pipe-message-subr + nil (format "cd '%s' && git am" proj)))) (provide 'magit)