diff options
-rw-r--r-- | lisp/init-dired.el | 7 | ||||
-rw-r--r-- | lisp/init-python.el | 9 | ||||
-rw-r--r-- | lisp/init-util.el | 6 |
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 |