Permalink
Browse files

* helm-elscreen.el: New

* helm-config.el: Move elscreen
  • Loading branch information...
1 parent 7d8197a commit 20b6beebc199dcec5fea6b049e44bfb6a17017bc @thierryvolpiatto thierryvolpiatto committed Mar 22, 2012
Showing with 72 additions and 43 deletions.
  1. +1 −43 helm-config.el
  2. +71 −0 helm-elscreen.el
View
@@ -49,6 +49,7 @@
(require 'helm-font)
(require 'helm-sys)
(require 'helm-misc)
+(require 'helm-elscreen nil t)
(require 'helm-w3m nil t)
(require 'helm-firefox nil t)
(require 'helm-bmkext nil t)
@@ -1016,49 +1017,6 @@ See also `helm-create--actions'.")
(insert candidate)))))
-;;; Elscreen
-;;
-;;
-(defun helm-find-buffer-on-elscreen (candidate)
- "Open buffer in new screen, if marked buffers open all in elscreens."
- (helm-require-or-error 'elscreen 'helm-find-buffer-on-elscreen)
- (helm-aif (helm-marked-candidates)
- (dolist (i it)
- (let ((target-screen (elscreen-find-screen-by-buffer
- (get-buffer i) 'create)))
- (elscreen-goto target-screen)))
- (let ((target-screen (elscreen-find-screen-by-buffer
- (get-buffer candidate) 'create)))
- (elscreen-goto target-screen))))
-
-(defun helm-elscreen-find-file (file)
- (helm-require-or-error 'elscreen 'helm-elscreen-find-file)
- (elscreen-find-file file))
-
-(defvar helm-c-source-elscreen
- '((name . "Elscreen")
- (candidates
- . (lambda ()
- (if (cdr (elscreen-get-screen-to-name-alist))
- (sort
- (loop for sname in (elscreen-get-screen-to-name-alist)
- append (list (format "[%d] %s" (car sname) (cdr sname))))
- #'(lambda (a b) (compare-strings a nil nil b nil nil))))))
- (action
- . (("Change Screen" .
- (lambda (candidate)
- (elscreen-goto (- (aref candidate 1) (aref "0" 0)))))
- ("Kill Screen(s)" .
- (lambda (candidate)
- (dolist (i (helm-marked-candidates))
- (elscreen-goto (- (aref i 1) (aref "0" 0)))
- (elscreen-kill))))
- ("Only Screen" .
- (lambda (candidate)
- (elscreen-goto (- (aref candidate 1) (aref "0" 0)))
- (elscreen-kill-others)))))))
-
-
;;; Generic action functions
;;
;;
View
@@ -0,0 +1,71 @@
+;;; helm-elscreen.el -- Elscreen support
+
+;; Copyright (C) 2012 Thierry Volpiatto <thierry.volpiatto@gmail.com>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+(eval-when-compile (require 'cl))
+(require 'helm)
+
+;;
+;;
+(defun helm-find-buffer-on-elscreen (candidate)
+ "Open buffer in new screen, if marked buffers open all in elscreens."
+ (helm-require-or-error 'elscreen 'helm-find-buffer-on-elscreen)
+ (helm-aif (helm-marked-candidates)
+ (dolist (i it)
+ (let ((target-screen (elscreen-find-screen-by-buffer
+ (get-buffer i) 'create)))
+ (elscreen-goto target-screen)))
+ (let ((target-screen (elscreen-find-screen-by-buffer
+ (get-buffer candidate) 'create)))
+ (elscreen-goto target-screen))))
+
+(defun helm-elscreen-find-file (file)
+ (helm-require-or-error 'elscreen 'helm-elscreen-find-file)
+ (elscreen-find-file file))
+
+(defvar helm-c-source-elscreen
+ '((name . "Elscreen")
+ (candidates
+ . (lambda ()
+ (if (cdr (elscreen-get-screen-to-name-alist))
+ (sort
+ (loop for sname in (elscreen-get-screen-to-name-alist)
+ append (list (format "[%d] %s" (car sname) (cdr sname))))
+ #'(lambda (a b) (compare-strings a nil nil b nil nil))))))
+ (action
+ . (("Change Screen" .
+ (lambda (candidate)
+ (elscreen-goto (- (aref candidate 1) (aref "0" 0)))))
+ ("Kill Screen(s)" .
+ (lambda (candidate)
+ (dolist (i (helm-marked-candidates))
+ (elscreen-goto (- (aref i 1) (aref "0" 0)))
+ (elscreen-kill))))
+ ("Only Screen" .
+ (lambda (candidate)
+ (elscreen-goto (- (aref candidate 1) (aref "0" 0)))
+ (elscreen-kill-others)))))))
+
+;;;###autoload
+(defun helm-elscreen ()
+ "Preconfigured helm to list elscreen."
+ (interactive)
+ (helm-other-buffer 'helm-c-source-elscreen "*Helm Elscreen*"))
+
+(provide 'helm-elscreen)
+
+;;; helm-elscreen.el ends here

0 comments on commit 20b6bee

Please sign in to comment.