2012-08-10 21:13:59 +02:00
|
|
|
|
;;; ein-helm.el --- Helm/anything commands
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2012 Takafumi Arakaki
|
|
|
|
|
|
|
|
|
|
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
|
|
|
|
|
|
|
|
|
;; This file is NOT part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; ein-helm.el 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.
|
|
|
|
|
|
|
|
|
|
;; ein-helm.el 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 ein-helm.el. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(eval-when-compile (require 'cl))
|
|
|
|
|
|
|
|
|
|
(declare-function anything-other-buffer "anything")
|
|
|
|
|
(declare-function helm-other-buffer "helm")
|
|
|
|
|
|
2012-09-05 22:47:29 +02:00
|
|
|
|
(require 'ein-kernel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Dynamic Variables
|
|
|
|
|
|
|
|
|
|
(defvar ein:helm-pattern 'helm-pattern
|
|
|
|
|
"Dynamically bound to one of `helm-pattern' or `anything-pattern'.")
|
|
|
|
|
|
|
|
|
|
(defvar ein:helm-kernel nil
|
|
|
|
|
"Dynamically bound to a kernel object.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; History search
|
|
|
|
|
|
|
|
|
|
(defvar ein:helm-source-history-search
|
|
|
|
|
'((name . "IPython history")
|
|
|
|
|
(candidates . (lambda ()
|
|
|
|
|
(ein:kernel-history-search-synchronously
|
|
|
|
|
ein:helm-kernel (eval ein:helm-pattern))))
|
|
|
|
|
(requires-pattern . 5)
|
|
|
|
|
(volatile)
|
|
|
|
|
(action . insert)
|
|
|
|
|
(delayed)
|
|
|
|
|
(multiline))
|
|
|
|
|
"Helm/anything source for searching kernel history.")
|
|
|
|
|
|
2012-09-05 22:51:21 +02:00
|
|
|
|
;;;###autoload
|
2012-09-05 22:47:29 +02:00
|
|
|
|
(defun anything-ein-kernel-history ()
|
|
|
|
|
"Search kernel execution history then insert the selected one."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((ein:helm-pattern 'anything-pattern)
|
|
|
|
|
(ein:helm-kernel (ein:get-kernel-or-error)))
|
|
|
|
|
(anything-other-buffer ein:helm-source-history-search "*anything ein*")))
|
|
|
|
|
|
2012-09-05 22:51:21 +02:00
|
|
|
|
;;;###autoload
|
2012-09-05 22:47:29 +02:00
|
|
|
|
(defun helm-ein-kernel-history ()
|
|
|
|
|
"Search kernel execution history then insert the selected one."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((ein:helm-pattern 'helm-pattern)
|
|
|
|
|
(ein:helm-kernel (ein:get-kernel-or-error)))
|
|
|
|
|
(helm-other-buffer ein:helm-source-history-search "*helm ein*")))
|
|
|
|
|
|
|
|
|
|
|
2012-09-05 22:51:04 +02:00
|
|
|
|
|
|
|
|
|
;;; Notebook buffers
|
2012-08-10 21:13:59 +02:00
|
|
|
|
|
|
|
|
|
(defvar ein:helm-source-notebook-buffers
|
|
|
|
|
'((name . "IPython notebook buffers")
|
2012-08-10 21:24:48 +02:00
|
|
|
|
(candidates . ein:notebook-opened-buffer-names)
|
2012-08-10 21:13:59 +02:00
|
|
|
|
(type . buffer))
|
|
|
|
|
"Helm/anything source for notebook buffers.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; "Export" sources to `helm/anything-c-source-*'
|
|
|
|
|
|
|
|
|
|
(defvaralias 'anything-c-source-ein-notebook-buffers
|
|
|
|
|
'ein:helm-source-notebook-buffers
|
|
|
|
|
"Alias to `anything-c-source-ein-notebook-buffers'")
|
|
|
|
|
|
|
|
|
|
(defvaralias 'helm-c-source-ein-notebook-buffers
|
|
|
|
|
'ein:helm-source-notebook-buffers
|
|
|
|
|
"Alias to `ein:helm-source-notebook-buffers'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Helm/anything commands
|
|
|
|
|
|
2012-09-01 20:51:55 +02:00
|
|
|
|
;;;###autoload
|
2012-08-10 21:13:59 +02:00
|
|
|
|
(defun anything-ein-notebook-buffers ()
|
2012-08-10 22:05:39 +02:00
|
|
|
|
"Choose opened notebook using anything.el interface."
|
2012-08-10 21:13:59 +02:00
|
|
|
|
(interactive)
|
|
|
|
|
(anything-other-buffer ein:helm-source-notebook-buffers "*anything ein*"))
|
|
|
|
|
|
2012-09-01 20:51:55 +02:00
|
|
|
|
;;;###autoload
|
2012-08-10 21:13:59 +02:00
|
|
|
|
(defun helm-ein-notebook-buffers ()
|
2012-08-10 22:05:39 +02:00
|
|
|
|
"Choose opened notebook using helm interface."
|
2012-08-10 21:13:59 +02:00
|
|
|
|
(interactive)
|
|
|
|
|
(helm-other-buffer ein:helm-source-notebook-buffers "*helm ein*"))
|
|
|
|
|
|
|
|
|
|
(provide 'ein-helm)
|
|
|
|
|
;;; ein-helm.el ends here
|