From 11c14b6357dbffb097bc985ef23d8b4827b027d3 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Wed, 12 May 2010 23:34:04 +0100 Subject: [PATCH] Put back `magit-list-buffers' and `magit-list-projects' as they might come in handy to others. --- magit.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index c61da5c9..1b8e679a 100644 --- a/magit.el +++ b/magit.el @@ -4047,6 +4047,34 @@ With prefix force the removal even it it hasn't been merged." ((diff) (magit-interactive-resolve (cadr info))))) -(provide 'magit) +(defun magit-list-buffers () + "Returns a list of magit buffers." + (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-dupes + (sort + (mapcar (lambda (b) + (save-excursion + (set-buffer b) + (directory-file-name default-directory))) + (magit-list-buffers)) + 'string=))) + +(provide 'magit) ;;; magit.el ends here