mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 09:31:39 -05:00
Merge branch 'imenu'
This commit is contained in:
commit
bc1c59e333
3 changed files with 38 additions and 1 deletions
|
@ -415,7 +415,9 @@ v0.1.1
|
|||
* Introduce :el:symbol:`ein:notebook-show-in-shared-output` command
|
||||
and :el:symbol:`ein:cell-max-num-outputs` configuration variable to
|
||||
truncate long output and show it in a separated buffer.
|
||||
* Add :el:symbol:`ein:pytools-pandas-to-ses`
|
||||
* Add :el:symbol:`ein:pytools-pandas-to-ses`.
|
||||
* Add Imenu support.
|
||||
|
||||
|
||||
v0.1
|
||||
----
|
||||
|
|
|
@ -122,6 +122,23 @@ Called via `ein:notebook-mumamo-mode-hook'."
|
|||
'ein:mumamo-indent-line-function-workaround)
|
||||
(ad-activate 'mumamo-indent-line-function)))
|
||||
|
||||
(defun ein:mumamo-imenu-setup-maybe ()
|
||||
"Set `imenu-create-index-function' if the current buffer is the
|
||||
notebook buffer.
|
||||
This function is called via `after-change-major-mode-hook', to set
|
||||
the variable every time visiting the different chunks.
|
||||
|
||||
.. note:: Making `imenu-create-index-function' permanent-local
|
||||
also solves the problem. However, this will make the variable
|
||||
permanent-local in *any* buffer, including the buffers
|
||||
irrelevant to EIN. Therefore, the current approach is taken.
|
||||
|
||||
This is the same workaround as `ein:ac-setup-maybe'."
|
||||
(when ein:notebook
|
||||
(ein:notebook-imenu-setup)))
|
||||
|
||||
(add-hook 'after-change-major-mode-hook 'ein:mumamo-imenu-setup-maybe)
|
||||
|
||||
|
||||
|
||||
;;; `ein:notebook-mumamo-mode'
|
||||
|
|
|
@ -1148,6 +1148,20 @@ as usual."
|
|||
(ein:kernel-kill kernel close-notebook (list ein:notebook))
|
||||
(funcall close-notebook ein:notebook)))))
|
||||
|
||||
|
||||
;;; Imenu
|
||||
|
||||
(defun ein:notebook-imenu-create-index ()
|
||||
"`imenu-create-index-function' for notebook buffer."
|
||||
(loop for cell in (ein:filter #'ein:headingcell-p
|
||||
(ein:notebook-get-cells ein:notebook))
|
||||
collect (cons (ein:cell-get-text cell)
|
||||
(ein:cell-input-pos-min cell))))
|
||||
|
||||
(defun ein:notebook-imenu-setup ()
|
||||
"Called via notebook mode hooks."
|
||||
(setq imenu-create-index-function #'ein:notebook-imenu-create-index))
|
||||
|
||||
|
||||
;;; Notebook mode
|
||||
|
||||
|
@ -1237,9 +1251,13 @@ Do not use `python-mode'. Use plain mode when MuMaMo is not installed::
|
|||
"IPython notebook mode without fancy coloring."
|
||||
(font-lock-mode))
|
||||
|
||||
(add-hook 'ein:notebook-plain-mode-hook 'ein:notebook-imenu-setup)
|
||||
|
||||
(define-derived-mode ein:notebook-python-mode python-mode "ein:python"
|
||||
"Use `python-mode' for whole notebook buffer.")
|
||||
|
||||
(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.
|
||||
|
|
Loading…
Add table
Reference in a new issue