summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-01-07 22:13:16 -0500
committerKyle Meyer <kyle@kyleam.com>2016-01-09 03:39:01 -0500
commitfbb0adb8f3403613014d41b6430e2c46fca5e1a5 (patch)
tree5d9562a576f44b1882913d38d07a680b8a2e6ffe /lisp
parent61d0552371cf350be2b9888759dfc57e9bcba3a5 (diff)
downloademacs.d-fbb0adb8f3403613014d41b6430e2c46fca5e1a5.tar.gz
Add km/mode-buffers function
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-dired.el7
-rw-r--r--lisp/init-python.el9
-rw-r--r--lisp/init-util.el6
3 files changed, 8 insertions, 14 deletions
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
index 8cb215e..ba976ea 100644
--- a/lisp/init-dired.el
+++ b/lisp/init-dired.el
@@ -65,12 +65,7 @@
(defun km/dired-completing-buffer ()
(completing-read "Dired buffer: "
- (-map 'buffer-name (km/dired-buffer-list))))
-
-(defun km/dired-buffer-list ()
- (--filter (with-current-buffer it
- (derived-mode-p 'dired-mode))
- (buffer-list)))
+ (mapcar #'buffer-name (km/mode-buffers 'dired-mode))))
(defun km/org-open-dired-marked-files (&optional arg)
"Open marked files (or next ARG) with `org-open-file'."
diff --git a/lisp/init-python.el b/lisp/init-python.el
index 3471a94..3af81ec 100644
--- a/lisp/init-python.el
+++ b/lisp/init-python.el
@@ -139,16 +139,9 @@ for a new string."
(setq km/python-shell-current-string (read-string "Python command: " initial))))
(python-shell-send-string km/python-shell-current-string))
-(defun km/python--shell-buffers ()
- (delq nil (mapcar (lambda (b)
- (with-current-buffer b
- (and (derived-mode-p 'inferior-python-mode)
- b)))
- (buffer-list))))
-
(defun km/python-shell--read-buffer ()
(let ((buf-alist (mapcar (lambda (b) (cons (buffer-name b) b))
- (km/python--shell-buffers))))
+ (km/mode-buffers 'inferior-python-mode))))
(if (= (length buf-alist) 1)
(cdr (car buf-alist))
(cdr (assoc-string (completing-read "Shell buffer: " buf-alist)
diff --git a/lisp/init-util.el b/lisp/init-util.el
index eea055d..c085738 100644
--- a/lisp/init-util.el
+++ b/lisp/init-util.el
@@ -20,6 +20,8 @@
;;; Code:
+(require 'dash)
+
;; Taken from
;; http://milkbox.net/note/single-file-master-emacs-configuration/.
(defmacro after (mode &rest body)
@@ -28,5 +30,9 @@
`(eval-after-load ,mode
'(progn ,@body)))
+(defun km/mode-buffers (mode)
+ (--filter (with-current-buffer it (derived-mode-p mode))
+ (buffer-list)))
+
(provide 'init-util)
;;; init-util.el ends here