mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-07 01:51:39 -05:00
Merge branch 'complete-on-dot'
This commit is contained in:
commit
1be099d4e7
4 changed files with 45 additions and 12 deletions
|
@ -307,6 +307,7 @@ Notebook
|
|||
.. el:variable:: ein:cell-autoexec-prompt
|
||||
.. el:variable:: ein:scratch-notebook-name-template
|
||||
.. el:variable:: ein:iexec-delay
|
||||
.. el:variable:: ein:complete-on-dot
|
||||
|
||||
Connect
|
||||
^^^^^^^
|
||||
|
@ -482,6 +483,8 @@ v0.1.1
|
|||
* Add auto-execution mode
|
||||
(see :el:symbol:`ein:connect-toggle-autoexec` and
|
||||
:el:symbol:`ein:notebook-turn-on-autoexec`).
|
||||
* Start completion when "." is inserted.
|
||||
Use :el:symbol:`ein:complete-on-dot` to disable this feature.
|
||||
|
||||
|
||||
v0.1
|
||||
|
|
|
@ -241,6 +241,14 @@ See also: `ein:connect-run-buffer', `ein:connect-eval-buffer'."
|
|||
(interactive)
|
||||
(ein:notebook-complete-at-point (ein:connect-get-notebook)))
|
||||
|
||||
(defun ein:connect-complete-dot ()
|
||||
"Insert dot and request completion."
|
||||
(interactive)
|
||||
(insert ".")
|
||||
(let ((notebook (ein:connect-get-notebook)))
|
||||
(when (and notebook (ein:kernel-live-p (ein:$notebook-kernel notebook)))
|
||||
(ein:notebook-complete-at-point notebook))))
|
||||
|
||||
(defun ein:connect-pop-to-notebook ()
|
||||
(interactive)
|
||||
(pop-to-buffer (ein:notebook-buffer (ein:connect-get-notebook))))
|
||||
|
@ -308,7 +316,8 @@ change the cells to run."
|
|||
\\{ein:connect-mode-map}"
|
||||
:lighter (:eval (ein:connect-mode-get-lighter))
|
||||
:keymap ein:connect-mode-map
|
||||
:group 'ein)
|
||||
:group 'ein
|
||||
(ein:complete-on-dot-install ein:connect-mode-map 'ein:connect-complete-dot))
|
||||
|
||||
|
||||
(provide 'ein-connect)
|
||||
|
|
|
@ -179,8 +179,7 @@ This is the same workaround as `ein:ac-setup-maybe'."
|
|||
ein:mumamo-chunk-headingcell
|
||||
)))
|
||||
|
||||
;; "Sync" `ein:notebook-mumamo-mode-map' with `ein:notebook-mode-map'.
|
||||
(setcdr ein:notebook-mumamo-mode-map (cdr ein:notebook-mode-map))
|
||||
(set-keymap-parent ein:notebook-mumamo-mode-map ein:notebook-mode-map)
|
||||
|
||||
(add-hook 'ein:notebook-mumamo-mode-hook 'ein:notebook-setup-kill-buffer-hook)
|
||||
(add-hook 'ein:notebook-mumamo-mode-hook
|
||||
|
|
|
@ -137,6 +137,21 @@ notebook. For global setting and more information, see
|
|||
(const :tag "Use global setting" nil))
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:complete-on-dot t
|
||||
"Start completion when inserting a dot. Note that
|
||||
`ein:use-auto-complete' (or `ein:use-auto-complete-superpack')
|
||||
must be `t' to enable this option. This variable has effect on
|
||||
notebook buffers and connected buffers."
|
||||
:type 'boolean
|
||||
:group 'ein)
|
||||
|
||||
(defun ein:complete-on-dot-install (map func)
|
||||
(if (and ein:complete-on-dot
|
||||
(or ein:use-auto-complete
|
||||
ein:use-auto-complete-superpack))
|
||||
(define-key map "." func)
|
||||
(define-key map "." nil)))
|
||||
|
||||
(defvar ein:notebook-after-rename-hook nil
|
||||
"Hooks to run after notebook is renamed successfully.
|
||||
Current buffer for these functions is set to the notebook buffer.")
|
||||
|
@ -977,6 +992,15 @@ pager buffer. You can explicitly specify the object by selecting it."
|
|||
(ein:kernel-if-ready (ein:$notebook-kernel ein:notebook)
|
||||
(ein:notebook-complete-at-point ein:notebook))))
|
||||
|
||||
(defun ein:notebook-complete-dot ()
|
||||
"Insert dot and request completion."
|
||||
(interactive)
|
||||
(insert ".")
|
||||
(when (and ein:notebook
|
||||
(ein:codecell-p (ein:notebook-get-current-cell))
|
||||
(ein:kernel-live-p (ein:$notebook-kernel ein:notebook)))
|
||||
(ein:notebook-complete-at-point ein:notebook)))
|
||||
|
||||
(defun ein:notebook-kernel-interrupt-command ()
|
||||
"Interrupt the kernel.
|
||||
This is equivalent to do ``C-c`` in the console program."
|
||||
|
@ -1260,9 +1284,6 @@ Do not use `python-mode'. Use plain mode when MuMaMo is not installed::
|
|||
if (functionp mode)
|
||||
return mode))
|
||||
|
||||
(defun ein:notebook-mode ()
|
||||
(funcall (ein:notebook-choose-mode)))
|
||||
|
||||
(defvar ein:notebook-mode-map (make-sparse-keymap))
|
||||
|
||||
(let ((map ein:notebook-mode-map))
|
||||
|
@ -1309,6 +1330,11 @@ Do not use `python-mode'. Use plain mode when MuMaMo is not installed::
|
|||
(define-key map (kbd "C-c C-,") 'ein:pytools-jump-back-command)
|
||||
map)
|
||||
|
||||
(defun ein:notebook-mode ()
|
||||
(funcall (ein:notebook-choose-mode))
|
||||
(ein:complete-on-dot-install
|
||||
ein:notebook-mode-map 'ein:notebook-complete-dot))
|
||||
|
||||
(define-derived-mode ein:notebook-plain-mode fundamental-mode "ein:notebook"
|
||||
"IPython notebook mode without fancy coloring."
|
||||
(font-lock-mode))
|
||||
|
@ -1320,12 +1346,8 @@ Do not use `python-mode'. Use plain mode when MuMaMo is not installed::
|
|||
|
||||
(add-hook 'ein:notebook-python-mode-hook 'ein:notebook-imenu-setup)
|
||||
|
||||
;; "Sync" `ein:notebook-plain-mode-map' with `ein:notebook-mode-map'.
|
||||
;; This way, `ein:notebook-plain-mode-map' automatically changes when
|
||||
;; `ein:notebook-mode-map' is changed.
|
||||
(setcdr ein:notebook-plain-mode-map (cdr ein:notebook-mode-map))
|
||||
|
||||
(setcdr ein:notebook-python-mode-map (cdr ein:notebook-mode-map))
|
||||
(set-keymap-parent ein:notebook-plain-mode-map ein:notebook-mode-map)
|
||||
(set-keymap-parent ein:notebook-python-mode-map ein:notebook-mode-map)
|
||||
|
||||
(defun ein:notebook-open-in-browser (&optional print)
|
||||
"Open current notebook in web browser.
|
||||
|
|
Loading…
Add table
Reference in a new issue