From a5a246c7340b6445888c8194ac93173b033cea50 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 13 Feb 2013 21:05:42 +0100 Subject: [PATCH 01/27] Check ein:kernel-live-p in ein:ac-* functions --- lisp/ein-ac.el | 5 +++-- lisp/ein-kernel.el | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index 71f664f6..536fcbe8 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -105,7 +105,8 @@ (symbol . "c"))) (defun ein:ac-request-in-background () - (ein:and-let* ((kernel (ein:get-kernel))) + (ein:and-let* ((kernel (ein:get-kernel)) + ((ein:kernel-live-p kernel))) (ein:completer-complete kernel :callbacks @@ -162,7 +163,7 @@ popup help string." (callbacks (list :object_info_reply (cons #'ein:ac-set-document candidate)))) (when (and candidate - kernel + (ein:kernel-live-p kernel) (not (get-text-property 0 'document candidate))) (ein:log 'debug "Requesting object info for AC candidate %S" candidate) diff --git a/lisp/ein-kernel.el b/lisp/ein-kernel.el index 741428b3..4046a4c2 100644 --- a/lisp/ein-kernel.el +++ b/lisp/ein-kernel.el @@ -252,6 +252,7 @@ (defun ein:kernel-live-p (kernel) (and + (ein:$kernel-p kernel) (ein:aand (ein:$kernel-shell-channel kernel) (ein:websocket-open-p it)) (ein:aand (ein:$kernel-iopub-channel kernel) (ein:websocket-open-p it)))) From 5b18c666e38b9689b13810467e30835a6a3c3260 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 13 Feb 2013 21:20:56 +0100 Subject: [PATCH 02/27] Make ein:jedi-complete work when kernel is dead Previously deferred:callback-post was not called for the deferred object from ein:jedi--completer-complete when the kernel is dead. It is called with an empty result now. --- lisp/ein-jedi.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lisp/ein-jedi.el b/lisp/ein-jedi.el index 8e7e1dae..f7924b97 100644 --- a/lisp/ein-jedi.el +++ b/lisp/ein-jedi.el @@ -36,16 +36,18 @@ '(ac-source-jedi-direct ac-source-ein-direct)) (defun ein:jedi--completer-complete () - (let ((d (deferred:new #'identity))) - (ein:and-let* ((kernel (ein:get-kernel)) - ((not (ac-cursor-on-diable-face-p))) - ((ein:kernel-live-p kernel))) - (ein:completer-complete - kernel - :callbacks - (list :complete_reply - (cons (lambda (d &rest args) (deferred:callback-post d args)) - d)))) + (let ((d (deferred:new #'identity)) + (kernel (ein:get-kernel))) + (if (and (ein:kernel-live-p kernel) + (not (ac-cursor-on-diable-face-p))) + (ein:completer-complete + kernel + :callbacks + (list :complete_reply + (cons (lambda (d &rest args) (deferred:callback-post d args)) + d))) + ;; Pass "no match" result when kernel the request was not sent: + (deferred:callback-post d (list nil nil))) d)) ;;;###autoload From fe682db22de297adef60affecac0e089f0732106 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 13 Feb 2013 21:24:09 +0100 Subject: [PATCH 03/27] Fix compile warnings in ein-ac.el and ein-jedi.el --- lisp/ein-ac.el | 4 ++-- lisp/ein-jedi.el | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index 536fcbe8..a845f3e4 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -111,7 +111,7 @@ kernel :callbacks (list :complete_reply - (cons (lambda (_ content _) + (cons (lambda (_ content __) (ein:ac-prepare-completion (plist-get content :matches))) nil))))) @@ -127,7 +127,7 @@ Call this function before calling `auto-complete'." (run-with-idle-timer 1 nil #'ein:ac-clear-cache))) (defun* ein:completer-finish-completing-ac - (-matched-text-not-used- + (matched-text matches &key (expand ac-expand-on-auto-complete) &allow-other-keys) diff --git a/lisp/ein-jedi.el b/lisp/ein-jedi.el index f7924b97..adbac9e5 100644 --- a/lisp/ein-jedi.el +++ b/lisp/ein-jedi.el @@ -28,9 +28,9 @@ (require 'jedi nil t) -(eval-when-compile (require 'ein-connect)) (require 'ein-ac) (require 'ein-completer) +(eval-when-compile (require 'ein-connect)) (defvar ein:jedi-dot-complete-sources '(ac-source-jedi-direct ac-source-ein-direct)) From e5b53e504309099200c37cf92777300aca580215 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 13 Feb 2013 21:46:24 +0100 Subject: [PATCH 04/27] Do not try dot-complete when in string literal etc. --- lisp/ein-jedi.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/ein-jedi.el b/lisp/ein-jedi.el index adbac9e5..43f84771 100644 --- a/lisp/ein-jedi.el +++ b/lisp/ein-jedi.el @@ -38,8 +38,7 @@ (defun ein:jedi--completer-complete () (let ((d (deferred:new #'identity)) (kernel (ein:get-kernel))) - (if (and (ein:kernel-live-p kernel) - (not (ac-cursor-on-diable-face-p))) + (if (ein:kernel-live-p kernel) (ein:completer-complete kernel :callbacks @@ -75,7 +74,8 @@ "Insert \".\" and run `ein:jedi-complete'." (interactive) (insert ".") - (ein:jedi-complete :expand nil)) + (unless (ac-cursor-on-diable-face-p) + (ein:jedi-complete :expand nil))) (defun ein:jedi-complete-on-dot-install (map) (ein:complete-on-dot-install map #'ein:jedi-dot-complete)) From 592d40f9eb6272f6c5cf1d5dd0f507cba4ca4f0b Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 23 Feb 2013 00:35:24 +0100 Subject: [PATCH 05/27] Mention C-u in ein:dev-start-debug document --- doc/source/index.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/index.rst b/doc/source/index.rst index 815004b6..dfea22ea 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -547,6 +547,9 @@ Debugging If you are interested in debugging EIN, you should start it with calling the command :el:symbol:`ein:dev-start-debug`. +If the bug is websocket related, you may need to run it with a +prefix key like this: ``C-u M-x ein:dev-start-debug RET`` to get +a backtrace. This command sets :el:symbol:`debug-on-error` to ``t`` and do some patching to debugger. This patching is required because printing EWOC objects freezes Emacs otherwise. It also changes log level to From 7f17f3bc4314d7089627d99049d674f67e6ed8d1 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 23 Feb 2013 16:35:08 +0100 Subject: [PATCH 06/27] Improve bug report template to avoid trouble like #104. --- lisp/ein-dev.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/ein-dev.el b/lisp/ein-dev.el index 9ab9af5c..6136d7f4 100644 --- a/lisp/ein-dev.el +++ b/lisp/ein-dev.el @@ -253,14 +253,18 @@ After finish writing it, please post it here: https://github.com/tkf/emacs-ipython-notebook/issues/new --> -## Please read \"Avoid standard Emacs traps\" first - -Please read \"Avoid standard Emacs traps\" section in -https://github.com/tkf/emacs-ipython-notebook/blob/master/CONTRIBUTING.md -and make sure that your problem is not the one of them. - -When done, remove this section from your bug report then fill the -next sections. +## Check list + +- [ ] I read \"Avoid standard Emacs traps\" section in + https://github.com/tkf/emacs-ipython-notebook/blob/master/CONTRIBUTING.md +- [ ] I checked that IPython works with the browser interface. +- [ ] I checked that the problem was not due to badly compiled + files. Removing `*.elc` files from source directory of EIN and + its dependencies did not solve the problem. +- [ ] I checked that the libraries are loaded from intended place. + (You can check the location in the \"System info\" section below) + +## Description of the problem you have ## Steps to reproduce the problem From 9a637921f15ce20de9b86b044fa6dbeda34ddda1 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 8 Mar 2013 14:10:37 +0100 Subject: [PATCH 07/27] Improve ein:shared-output-eval-string --- lisp/ein-shared-output.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/ein-shared-output.el b/lisp/ein-shared-output.el index 42d80f86..84defa03 100644 --- a/lisp/ein-shared-output.el +++ b/lisp/ein-shared-output.el @@ -65,9 +65,24 @@ (defmethod ein:cell--handle-output ((cell ein:shared-output-cell) msg-type content -metadata-not-used-) - (ein:log 'info "Got output '%s' in the shared buffer." msg-type) + ;; Show short message + (ein:case-equal msg-type + (("pyout") + (let ((num (plist-get content :execution_count)) + (text (plist-get (plist-get content :data) :text/plain))) + (when text + (ein:log 'info "Out[%s]: %s" num (car (split-string text "\n")))))) + (("stream") + (let ((stream (or (plist-get content :stream) "stdout")) + (text (plist-get content :data))) + (when text + (ein:log 'info "%s: %s" stream (car (split-string text "\n")))))) + (t + (ein:log 'info "Got output '%s' in the shared buffer." msg-type))) + ;; Open `ein:shared-output-buffer-name' if necessary (when (oref cell :popup) (pop-to-buffer (ein:shared-output-create-buffer))) + ;; Finally do the normal drawing (call-next-method)) From 76591e007bb2b3be920e8b2d6c011f863a601f62 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 10 Mar 2013 08:11:30 +0100 Subject: [PATCH 08/27] Use region as default code for ein:shared-output-eval-string --- lisp/ein-shared-output.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/ein-shared-output.el b/lisp/ein-shared-output.el index 84defa03..07401bd6 100644 --- a/lisp/ein-shared-output.el +++ b/lisp/ein-shared-output.el @@ -199,7 +199,10 @@ shared output buffer. You can open the buffer by the command ;; ... so error will be raised before user typing code if it ;; is impossible to execute (code (read-string - "IP[y]: " nil 'ein:shared-output-eval-string-history))) + "IP[y]: " + (when (region-active-p) + (buffer-substring (region-beginning) (region-end))) + 'ein:shared-output-eval-string-history))) (list code nil t kernel))) (unless kernel (setq kernel (ein:get-kernel-or-error))) (let ((cell (ein:shared-output-get-cell))) From 203ff9998741ab6242f6090d4013dc72ce7b374d Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 12 Apr 2013 18:20:35 +0200 Subject: [PATCH 09/27] Register ein:worksheet-execute-all-cell to menu Add it to document also. fixes #63 --- doc/source/index.rst | 1 + lisp/ein-notebook.el | 2 ++ 2 files changed, 3 insertions(+) diff --git a/doc/source/index.rst b/doc/source/index.rst index dfea22ea..1def96d1 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -251,6 +251,7 @@ The following keybinds are available in notebook buffers. :replace: s/C-c TAB/C-c C-i/ s/C-c RET/C-c C-m/ +.. el:function:: ein:worksheet-execute-all-cell .. el:function:: ein:worksheet-delete-cell .. el:function:: ein:junk-rename .. el:function:: ein:notebook-kill-all-buffers diff --git a/lisp/ein-notebook.el b/lisp/ein-notebook.el index 806b747e..f392592f 100644 --- a/lisp/ein-notebook.el +++ b/lisp/ein-notebook.el @@ -1186,6 +1186,8 @@ This hook is run regardless the actual major mode used." ("Execute cell and insert below" ein:worksheet-execute-cell-and-insert-below :active (ein:worksheet-at-codecell-p)) + ("Execute all" + ein:worksheet-execute-all-cell) ("Turn on auto execution flag" ein:worksheet-turn-on-autoexec :active (ein:worksheet-at-codecell-p)) ("Evaluate code in minibuffer" ein:shared-output-eval-string) From 1fd6bbe3059cf8bfd2b0567eac5dbe2813dc08ec Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:01:49 +0200 Subject: [PATCH 10/27] Use git to install developmental version of IPython Recent changes in IPython requires git submodule for installing developmental version. --- tools/requirement-ipy.dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/requirement-ipy.dev.txt b/tools/requirement-ipy.dev.txt index 24c0eaa2..8d855748 100644 --- a/tools/requirement-ipy.dev.txt +++ b/tools/requirement-ipy.dev.txt @@ -1,4 +1,4 @@ -https://github.com/ipython/ipython/tarball/master +-e git://github.com/ipython/ipython.git#egg=ipython pyzmq tornado jinja2 From becd04fc53d3137691bfac16a4c20bcec3f18059 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:05:26 +0200 Subject: [PATCH 11/27] Refactor Makefile; add clean and purge --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9e95914f..09ff3df8 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,12 @@ testein: test-requirements interactive-testein: test-requirements ${MAKE} TESTEIN_OPTS="--no-batch" testein-1 +clean: ert-clean + rm -f lisp/*.elc + +purge: clean + rm -rf env log + submodule: git submodule update --init @@ -24,15 +30,9 @@ ert-clean: env-ipy.%: tools/makeenv.sh env/ipy.$* tools/requirement-ipy.$*.txt -env-clean: - rm -rf env - log: mkdir log -log-clean: - rm -rf log - test-requirements: ert-compile env-ipy.$(IPY_VERSION) travis-ci-testein: test-requirements From 2c615e7b8666d865f611ba0735948912126d1f71 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:12:03 +0200 Subject: [PATCH 12/27] Ignore travis failures with IPython 0.12.* --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index b6ca410a..d68910e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,12 @@ env: - EIN_TEST_TARGET=travis-ci-zeroein EMACS=emacs-snapshot matrix: allow_failures: + # IPY_VERSION=0.12.* + - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.1 EMACS=emacs + - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.0 EMACS=emacs + - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.1 EMACS=emacs24 + - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.0 EMACS=emacs24 + # EMACS=emacs-snapshot - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=dev EMACS=emacs-snapshot - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.13.0 EMACS=emacs-snapshot - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.1 EMACS=emacs-snapshot From e1bcfe28edbcf7c3132add6e93948fd3eec37bb4 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:20:45 +0200 Subject: [PATCH 13/27] Use tornado 2.4.1 when testing against IPython 0.12.* --- tools/requirement-ipy.0.12.0.txt | 2 +- tools/requirement-ipy.0.12.1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/requirement-ipy.0.12.0.txt b/tools/requirement-ipy.0.12.0.txt index 4760052b..dab2351d 100644 --- a/tools/requirement-ipy.0.12.0.txt +++ b/tools/requirement-ipy.0.12.0.txt @@ -1,3 +1,3 @@ ipython==0.12 pyzmq -tornado +tornado==2.4.1 diff --git a/tools/requirement-ipy.0.12.1.txt b/tools/requirement-ipy.0.12.1.txt index b4b2b783..4f27de61 100644 --- a/tools/requirement-ipy.0.12.1.txt +++ b/tools/requirement-ipy.0.12.1.txt @@ -1,3 +1,3 @@ ipython==0.12.1 pyzmq -tornado +tornado==2.4.1 From cbfc531671249830e3ddfde665e0a742f193904b Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:34:29 +0200 Subject: [PATCH 14/27] Use pyzmq 2.2.0.1 when testing against IPython 0.12.* --- tools/requirement-ipy.0.12.0.txt | 2 +- tools/requirement-ipy.0.12.1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/requirement-ipy.0.12.0.txt b/tools/requirement-ipy.0.12.0.txt index dab2351d..d847df76 100644 --- a/tools/requirement-ipy.0.12.0.txt +++ b/tools/requirement-ipy.0.12.0.txt @@ -1,3 +1,3 @@ ipython==0.12 -pyzmq +pyzmq==2.2.0.1 tornado==2.4.1 diff --git a/tools/requirement-ipy.0.12.1.txt b/tools/requirement-ipy.0.12.1.txt index 4f27de61..3b10878b 100644 --- a/tools/requirement-ipy.0.12.1.txt +++ b/tools/requirement-ipy.0.12.1.txt @@ -1,3 +1,3 @@ ipython==0.12.1 -pyzmq +pyzmq==2.2.0.1 tornado==2.4.1 From 6fd2a2adeb3ab9404712fa71398824ed7590ff07 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 06:53:10 +0200 Subject: [PATCH 15/27] Record Python package information --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 09ff3df8..fbf9ea15 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ IPYTHON = env/ipy.$(IPY_VERSION)/bin/ipython IPY_VERSION = 0.13.0 TESTEIN = tools/testein.py TESTEIN_OPTS = +PKG_INFO = \ +grep '^Version' \ +env/ipy.$(IPY_VERSION)/lib/python*/site-packages/*.egg-info/PKG-INFO \ +| sed -r 's%.*/site-packages/(.*)-py.*\.egg-info/.*:Version: (.*)$$%\1\t\2%' testein: test-requirements ${MAKE} testein-1 @@ -16,6 +20,11 @@ clean: ert-clean purge: clean rm -rf env log +pkg-info: + @echo "**************************************************" + @echo "Installed Python Packages" + $(PKG_INFO) + submodule: git submodule update --init @@ -34,6 +43,7 @@ log: mkdir log test-requirements: ert-compile env-ipy.$(IPY_VERSION) + ${MAKE} pkg-info travis-ci-testein: test-requirements ${MAKE} testein-2 From d7cab8a225900fc037f57d679380e6442d997016 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 May 2013 07:12:38 +0200 Subject: [PATCH 16/27] Unfreeze tornado --- tools/requirement-ipy.0.12.0.txt | 2 +- tools/requirement-ipy.0.12.1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/requirement-ipy.0.12.0.txt b/tools/requirement-ipy.0.12.0.txt index d847df76..9b32f8e3 100644 --- a/tools/requirement-ipy.0.12.0.txt +++ b/tools/requirement-ipy.0.12.0.txt @@ -1,3 +1,3 @@ ipython==0.12 pyzmq==2.2.0.1 -tornado==2.4.1 +tornado diff --git a/tools/requirement-ipy.0.12.1.txt b/tools/requirement-ipy.0.12.1.txt index 3b10878b..ad1762d1 100644 --- a/tools/requirement-ipy.0.12.1.txt +++ b/tools/requirement-ipy.0.12.1.txt @@ -1,3 +1,3 @@ ipython==0.12.1 pyzmq==2.2.0.1 -tornado==2.4.1 +tornado From 819e3e3df3b35fc50e5c672aa83525ce4a924754 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 25 May 2013 22:17:17 +0200 Subject: [PATCH 17/27] Fix: unintended text was inserted by dot-complete --- lisp/ein-ac.el | 3 ++- lisp/ein-jedi.el | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index a845f3e4..86cc3f4d 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -142,7 +142,8 @@ compatibility with `ein:completer-finish-completing-default'." (ein:ac-prepare-completion matches) (when matches ; No auto-complete drop-down list when no matches (let ((ac-expand-on-auto-complete expand)) - (auto-complete '(ac-source-ein-direct))))) + (ac-start)))) +;; Why `ac-start'? See: `jedi:complete'. (defun ein:ac-clear-cache () (setq ein:ac-cache-matches diff --git a/lisp/ein-jedi.el b/lisp/ein-jedi.el index 43f84771..7e6184b0 100644 --- a/lisp/ein-jedi.el +++ b/lisp/ein-jedi.el @@ -67,7 +67,8 @@ replies (ein:ac-prepare-completion matches) (let ((ac-expand-on-auto-complete expand)) - (auto-complete ein:jedi-dot-complete-sources)))))))) + (ac-start)))))))) +;; Why `ac-start'? See: `jedi:complete'. ;;;###autoload (defun ein:jedi-dot-complete () From b12b91da7acd315fd6051759f212285b2de88600 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 5 Jun 2013 01:43:49 +0200 Subject: [PATCH 18/27] Add ein:slice-image This is a workaround for issue #94. --- lisp/ein-cell.el | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lisp/ein-cell.el b/lisp/ein-cell.el index 0052f12a..e6d1e285 100644 --- a/lisp/ein-cell.el +++ b/lisp/ein-cell.el @@ -130,6 +130,18 @@ is on. See also `ein:connect-aotoexec-lighter'." :type 'string :group 'ein) +(defcustom ein:slice-image nil + "[EXPERIMENTAL] When non-`nil', use `insert-sliced-image' when +drawing images. If it is of the form of ``(ROWS COLS)``, it is +passed to the corresponding arguments of `insert-sliced-image'. + +.. FIXME: ROWS and COLS must be determined dynamically by measuring + the size of iamge and Emacs window. + +See also: https://github.com/tkf/emacs-ipython-notebook/issues/94" + :type 'boolean + :group 'ein) + ;;; EIEIO related utils @@ -142,6 +154,16 @@ is on. See also `ein:connect-aotoexec-lighter'." `(when (slot-boundp ,obj ,slot) (oref ,obj ,slot))) + +;;; Utils +(defun ein:insert-image (&rest args) + (let ((img (apply #'create-image args))) + (if ein:slice-image + (destructuring-bind (&optional rows cols) + (when (listp ein:slice-image) ein:slice-image) + (insert-sliced-image img nil nil (or rows 20) cols)) + (insert-image img)))) + ;;; Cell classes @@ -886,9 +908,9 @@ prettified text thus be used instead of HTML type." ((latex text) (ein:insert-read-only (plist-get json type))) (svg - (insert-image (create-image value key t))) + (ein:insert-image value key t)) ((png jpeg) - (insert-image (create-image (base64-decode-string value) key t)))))) + (ein:insert-image (base64-decode-string value) key t))))) (defun ein:cell-append-text (data &rest properties) ;; escape ANSI in plaintext: From ff622a6468f8ebb465ee000d510f5ee836273e48 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Mon, 10 Jun 2013 19:56:46 +0200 Subject: [PATCH 19/27] Fix how ws_url is set IPython notebook 1.0.dev sends empty ws_url as of this PR https://github.com/ipython/ipython/pull/3307 --- lisp/ein-kernel.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/ein-kernel.el b/lisp/ein-kernel.el index 4046a4c2..8d6a112e 100644 --- a/lisp/ein-kernel.el +++ b/lisp/ein-kernel.el @@ -139,7 +139,7 @@ (ein:log 'info "Kernel started: %s" kernel_id) (setf (ein:$kernel-running kernel) t) (setf (ein:$kernel-kernel-id kernel) kernel_id) - (setf (ein:$kernel-ws-url kernel) ws_url) + (setf (ein:$kernel-ws-url kernel) (ein:kernel--ws-url kernel ws_url)) (setf (ein:$kernel-kernel-url kernel) (concat (ein:$kernel-base-url kernel) "/" kernel_id))) (ein:kernel-start-channels kernel) @@ -155,6 +155,15 @@ (ein:kernel--handle-iopub-reply kernel packet)))))) +(defun ein:kernel--ws-url (kernel ws_url) + "Use `ein:$kernel-url-or-port' if WS_URL is an empty string. +See: https://github.com/ipython/ipython/pull/3307" + (if (string-match-p "^wss?://" ws_url) + ws_url + (let ((ein:url-localhost-template "ws://127.0.0.1:%s")) + (ein:url (ein:$kernel-url-or-port kernel))))) + + (defun ein:kernel--websocket-closed (kernel ws-url early) (if early (ein:display-warning From 7901e90db7fbdfce56ac7166b388da5599cf83cd Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 11 Jun 2013 16:49:49 +0200 Subject: [PATCH 20/27] Default ein:query-timeout is nil if curl is used this is to address #114 --- doc/source/index.rst | 2 ++ lisp/ein-query.el | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 1def96d1..d322dbac 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -564,6 +564,8 @@ Change Log v0.2.1 ------ +* :el:symbol:`ein:query-timeout` is `nil` if `curl` backend is used + by request.el_. * History search interface (:el:symbol:`helm-ein-kernel-history` and :el:symbol:`anything-ein-kernel-history`) discards duplications. This functionality requires at least version 4.0 of IPython kernel. diff --git a/lisp/ein-query.el b/lisp/ein-query.el index 1d330ede..bf3dc34d 100644 --- a/lisp/ein-query.el +++ b/lisp/ein-query.el @@ -41,10 +41,14 @@ ;;; Variables -(defcustom ein:query-timeout 1000 +(defcustom ein:query-timeout + (if (eq request-backend 'url-retrieve) 1000 nil) "Default query timeout for HTTP access in millisecond. Setting this to `nil' means no timeout. +If you have ``curl`` command line program, it is automatically set to +`nil' as ``curl`` is reliable than `url-retrieve' therefore no need for +a workaround (see below). If you do the same operation before the timeout, old operation will be canceled \(see also `ein:query-singleton-ajax'). From 87e88bc179145d26ecdfcf5a92c70e4b033fb34c Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 11 Jun 2013 18:20:34 +0200 Subject: [PATCH 21/27] Use environment variable EMACS, if defined --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d68910e6..e12a07ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,4 +42,4 @@ matrix: - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.1 EMACS=emacs-snapshot - env: EIN_TEST_TARGET=travis-ci-testein IPY_VERSION=0.12.0 EMACS=emacs-snapshot script: - make $EIN_TEST_TARGET EMACS=$EMACS IPY_VERSION=$IPY_VERSION + make $EIN_TEST_TARGET IPY_VERSION=$IPY_VERSION diff --git a/Makefile b/Makefile index fbf9ea15..72f40edc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -EMACS = emacs +EMACS ?= emacs IPYTHON = env/ipy.$(IPY_VERSION)/bin/ipython IPY_VERSION = 0.13.0 TESTEIN = tools/testein.py From b7a4692f6915fc08819fc8e9a49d9947ecec6653 Mon Sep 17 00:00:00 2001 From: "Jessica B. Hamrick" Date: Fri, 28 Jun 2013 13:15:09 -0700 Subject: [PATCH 22/27] Don't use GNU arguments for ps Fixes #119 --- tools/testein.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testein.py b/tools/testein.py index d5f5a4c9..e493b7a9 100755 --- a/tools/testein.py +++ b/tools/testein.py @@ -376,8 +376,8 @@ def command(self): def kill_subprocesses(pid, include=lambda x: True): from subprocess import Popen, PIPE import signal - command = [ - 'ps', '--ppid', str(pid), '--format', 'pid,cmd', '--no-headers'] + + command = ['ps', '-e', '-o', 'ppid,pid,command'] proc = Popen(command, stdout=PIPE, stderr=PIPE) (stdout, stderr) = proc.communicate() if proc.returncode != 0: @@ -386,10 +386,10 @@ def kill_subprocesses(pid, include=lambda x: True): '{2}'.format(command, proc.returncode, stderr)) for line in map(str.strip, stdout.splitlines()): - (pid, cmd) = line.split(' ', 1) - if include(cmd): - print "Killing PID={0} COMMAND={1}".format(pid, cmd) - os.kill(int(pid), signal.SIGINT) + (cmd_ppid, cmd_pid, cmd) = line.split(None, 2) + if cmd_ppid == str(pid) and include(cmd): + print "Killing PID={0} COMMAND={1}".format(cmd_pid, cmd) + os.kill(int(cmd_pid), signal.SIGINT) def construct_command(args): From 372c7f619c4787ee86eefa8376397e5c8b53fd3c Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 23 Mar 2013 16:43:11 +0100 Subject: [PATCH 23/27] Disable caching complete candidates ein:ac-clear-cache takes too much time by the result of profiler.el. Also, as ac-source-ein-cached sends request in background [1], there is no need for caching anymore. [1] 865a96f3d2969d8addcfac545c63bf851904776a --- lisp/ein-ac.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index 86cc3f4d..046ea7a4 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -88,9 +88,6 @@ (defun ein:ac-direct-get-matches () (ein:ac-chunk-candidates-from-list ein:ac-direct-matches)) -(defun ein:ac-cache-get-matches () - (ein:ac-chunk-candidates-from-list ein:ac-cache-matches)) - (ac-define-source ein-direct '((candidates . ein:ac-direct-get-matches) (requires . 0) @@ -98,7 +95,7 @@ (symbol . "s"))) (ac-define-source ein-cached - '((candidates . ein:ac-cache-get-matches) + '((candidates . ein:ac-direct-get-matches) (requires . 0) (prefix . ein:ac-chunk-beginning) (init . ein:ac-request-in-background) @@ -122,9 +119,7 @@ "Prepare `ac-source-ein-direct' using MATCHES from kernel. Call this function before calling `auto-complete'." (when matches - (setq ein:ac-direct-matches matches) ; let-binding won't work - (setq ein:ac-cache-matches (append matches ein:ac-cache-matches)) - (run-with-idle-timer 1 nil #'ein:ac-clear-cache))) + (setq ein:ac-direct-matches matches))) ; let-binding won't work (defun* ein:completer-finish-completing-ac (matched-text From 5845dc6e352e468530fd4abc7204e597ec6d95a7 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 11 Jun 2013 20:12:35 +0200 Subject: [PATCH 24/27] Remove unused code from ein-ac.el --- lisp/ein-ac.el | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index 046ea7a4..1c9aca53 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -39,8 +39,10 @@ (default-value 'ac-sources)) "Extra `ac-sources' used in notebook.") +(make-obsolete-variable 'ein:ac-max-cache nil "0.1.2") (defcustom ein:ac-max-cache 1000 - "Maximum number of cache to store." + "[This value is not used anymore!] +Maximum number of cache to store." :type 'integer :group 'ein) @@ -79,8 +81,6 @@ ;;; AC Source -(defvar ein:ac-cache-matches nil) - (defvar ein:ac-direct-matches nil "Variable to store completion candidates for `auto-completion'.") ;; FIXME: Maybe this should be buffer-local? @@ -140,11 +140,6 @@ compatibility with `ein:completer-finish-completing-default'." (ac-start)))) ;; Why `ac-start'? See: `jedi:complete'. -(defun ein:ac-clear-cache () - (setq ein:ac-cache-matches - (setcdr (nthcdr (1- ein:ac-max-cache) - (delete-dups ein:ac-cache-matches)) nil))) - ;;; Async document request hack From a1ddf7a7a913679b7248665552b325fdb4cd4a47 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 11 Jun 2013 20:34:28 +0200 Subject: [PATCH 25/27] Rename: ein-cached -> ein-async --- lisp/ein-ac.el | 9 +++++++-- lisp/ein-connect.el | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/ein-ac.el b/lisp/ein-ac.el index 1c9aca53..017ea630 100644 --- a/lisp/ein-ac.el +++ b/lisp/ein-ac.el @@ -94,13 +94,18 @@ Maximum number of cache to store." (prefix . ein:ac-chunk-beginning) (symbol . "s"))) -(ac-define-source ein-cached +(ac-define-source ein-async '((candidates . ein:ac-direct-get-matches) (requires . 0) (prefix . ein:ac-chunk-beginning) (init . ein:ac-request-in-background) (symbol . "c"))) +(define-obsolete-function-alias 'ac-complete-ein-cached 'ac-complete-ein-async + "0.2.1") +(define-obsolete-variable-alias 'ac-source-ein-cached 'ac-source-ein-async + "0.2.1") + (defun ein:ac-request-in-background () (ein:and-let* ((kernel (ein:get-kernel)) ((ein:kernel-live-p kernel))) @@ -200,7 +205,7 @@ first candidate when the `ac-menu' pops up." (defun ein:ac-setup () "Call this function from mode hook (see `ein:ac-config')." - (setq ac-sources (append '(ac-source-ein-cached) ein:ac-sources))) + (setq ac-sources (append '(ac-source-ein-async) ein:ac-sources))) (defun ein:ac-setup-maybe () "Setup `ac-sources' for mumamo. diff --git a/lisp/ein-connect.el b/lisp/ein-connect.el index f5f3db0f..03c50cec 100644 --- a/lisp/ein-connect.el +++ b/lisp/ein-connect.el @@ -204,7 +204,7 @@ notebooks." (not ein:%connect%)) (let ((connection (ein:connect-setup notebook buffer))) (when (ein:eval-if-bound 'ac-sources) - (push 'ac-source-ein-cached ac-sources)) + (push 'ac-source-ein-async ac-sources)) (ein:connect-mode) (ein:log 'info "Connected to %s" (ein:$notebook-notebook-name notebook)) From bc32b00d2af4d77c8e4fd44ec82cd26acd982728 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 11 Jun 2013 20:35:34 +0200 Subject: [PATCH 26/27] Update changelog --- doc/source/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/index.rst b/doc/source/index.rst index d322dbac..11769f23 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -564,6 +564,10 @@ Change Log v0.2.1 ------ +* Cached auto-complete is removed. + :el:symbol:`ac-source-ein-cached` and :el:symbol:`ac-complete-ein-cached` + are obsolete. + :el:symbol:`ein:ac-max-cache` has no effect now. * :el:symbol:`ein:query-timeout` is `nil` if `curl` backend is used by request.el_. * History search interface (:el:symbol:`helm-ein-kernel-history` and From d62dc59869d436385efa940ba20a737bb8b9e5fd Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Mon, 17 Mar 2014 19:14:02 +0100 Subject: [PATCH 27/27] Require 'cc-mode in ein-utils.el It looks like in new Emacs version (> 24.3?), c-mode-syntax-table is not available by default. --- lisp/ein-utils.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/ein-utils.el b/lisp/ein-utils.el index f665e649..53236aba 100644 --- a/lisp/ein-utils.el +++ b/lisp/ein-utils.el @@ -26,6 +26,7 @@ ;;; Code: (eval-when-compile (require 'cl)) +(require 'cc-mode) (require 'json)