mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-09 03:46:38 -04:00
Merge branch 'show-in-shared-output'
This commit is contained in:
commit
0c54c00a68
4 changed files with 50 additions and 3 deletions
|
@ -300,6 +300,7 @@ Notebook
|
|||
.. el:variable:: ein:notebook-console-executable
|
||||
.. el:variable:: ein:notebook-console-args
|
||||
.. el:variable:: ein:cell-traceback-level
|
||||
.. el:variable:: ein:cell-max-num-outputs
|
||||
.. el:variable:: ein:scratch-notebook-name-template
|
||||
|
||||
Connect
|
||||
|
@ -409,6 +410,9 @@ v0.1.1
|
|||
* Plain text type output is favored over LaTeX type output
|
||||
(previous setting was opposite).
|
||||
* Add :el:symbol:`ein:notebook-rename-to-scratch-command`.
|
||||
* 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.
|
||||
|
||||
v0.1
|
||||
----
|
||||
|
|
|
@ -87,6 +87,13 @@ using the command `ein:notebook-view-traceback'."
|
|||
(const :tag "Show all traceback" nil))
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:cell-max-num-outputs 5
|
||||
"Number of maximum outputs to be shown by default.
|
||||
To view full output, use `ein:notebook-show-in-shared-output'."
|
||||
:type '(choice (integer :tag "Number of outputs to show" 5)
|
||||
(const :tag "Show all traceback" nil))
|
||||
:group 'ein)
|
||||
|
||||
|
||||
|
||||
;;; EIEIO related utils
|
||||
|
@ -167,7 +174,9 @@ slot.")))
|
|||
(("html") 'ein:htmlcell)
|
||||
(("markdown") 'ein:markdowncell)
|
||||
(("raw") 'ein:rawcell)
|
||||
(("heading") 'ein:headingcell)))
|
||||
(("heading") 'ein:headingcell)
|
||||
;; Defined in ein-shared-output.el:
|
||||
(("shared-output") 'ein:shared-output-cell)))
|
||||
|
||||
(defun ein:cell-from-type (type &rest args)
|
||||
(apply (ein:cell-class-from-type type) "Cell" args))
|
||||
|
@ -401,8 +410,14 @@ Called from ewoc pretty printer via `ein:cell-pp'."
|
|||
(defun ein:cell-insert-output (index cell)
|
||||
"Insert INDEX-th output of the CELL in the buffer.
|
||||
Called from ewoc pretty printer via `ein:cell-pp'."
|
||||
(if (oref cell :collapsed)
|
||||
(if (or (oref cell :collapsed)
|
||||
(and ein:cell-max-num-outputs
|
||||
(> index ein:cell-max-num-outputs)))
|
||||
(progn
|
||||
(when (and (not (oref cell :collapsed))
|
||||
(= (1+ index) ein:cell-max-num-outputs))
|
||||
;; The first output which exceeds `ein:cell-max-num-outputs'.
|
||||
(ein:insert-read-only "\n"))
|
||||
(ein:insert-read-only ".")
|
||||
(when (= (1+ index) (ein:cell-num-outputs cell))
|
||||
(ein:insert-read-only "\n")))
|
||||
|
|
|
@ -786,6 +786,14 @@ Do not clear input prompts when the prefix argument is given."
|
|||
(ein:notebook-empty-undo-maybe)))
|
||||
(ein:log 'error "Not in notebook buffer!")))
|
||||
|
||||
(defun ein:notebook-show-in-shared-output ()
|
||||
"Show truncated code cell ouput in shared-output buffer.
|
||||
See also `ein:cell-max-num-outputs' to how to truncate long
|
||||
output."
|
||||
(interactive)
|
||||
(ein:notebook-with-cell #'ein:codecell-p
|
||||
(ein:shared-output-show-code-cell cell)))
|
||||
|
||||
|
||||
;;; Traceback
|
||||
|
||||
|
@ -1187,6 +1195,7 @@ Do not use `python-mode'. Use plain mode when MuMaMo is not installed::
|
|||
(define-key map "\C-c\C-v" 'ein:notebook-set-collapsed-all-command)
|
||||
(define-key map "\C-c\C-l" 'ein:notebook-clear-output-command)
|
||||
(define-key map (kbd "C-c C-S-l") 'ein:notebook-clear-all-output-command)
|
||||
(define-key map (kbd "C-c C-;") 'ein:notebook-show-in-shared-output)
|
||||
(define-key map "\C-c\C-k" 'ein:notebook-kill-cell-command)
|
||||
(define-key map "\C-c\M-w" 'ein:notebook-copy-cell-command)
|
||||
(define-key map "\C-c\C-w" 'ein:notebook-copy-cell-command)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
(defclass ein:$shared-output ()
|
||||
((cell :initarg :cell :type ein:shared-output-cell)
|
||||
(events :initarg :events :type ein:events)
|
||||
(ewoc :initarg :ewoc :type ewoc)))
|
||||
|
||||
(defvar ein:@shared-output nil
|
||||
|
@ -102,7 +103,8 @@
|
|||
(erase-buffer)
|
||||
(ein:shared-output-bind-events events)
|
||||
(setq ein:@shared-output
|
||||
(ein:$shared-output "SharedOutput" :ewoc ewoc :cell cell))
|
||||
(ein:$shared-output "SharedOutput" :ewoc ewoc :cell cell
|
||||
:events events))
|
||||
(ein:cell-enter-last cell))
|
||||
(setq buffer-read-only t)
|
||||
(ein:shared-output-mode)
|
||||
|
@ -129,6 +131,23 @@ Create a cell if the buffer has none."
|
|||
(ein:shared-output-get-or-create)
|
||||
(pop-to-buffer (ein:shared-output-create-buffer)))
|
||||
|
||||
(defmethod ein:shared-output-show-code-cell ((cell ein:codecell))
|
||||
"Show code CELL in shared-output buffer.
|
||||
Note that this function assumed to be called in the buffer
|
||||
where CELL locates."
|
||||
(let ((new (ein:cell-convert cell "shared-output")))
|
||||
;; Make sure `ein:@shared-output' is initialized:
|
||||
(ein:shared-output-get-or-create)
|
||||
(with-current-buffer (ein:shared-output-create-buffer)
|
||||
(let ((inhibit-read-only t)
|
||||
(ein:cell-max-num-outputs nil))
|
||||
(oset new :ewoc (oref ein:@shared-output :ewoc))
|
||||
(oset new :events (oref ein:@shared-output :events))
|
||||
(erase-buffer) ; because there are only one cell anyway
|
||||
(oset ein:@shared-output :cell new)
|
||||
(ein:cell-enter-last new)
|
||||
(pop-to-buffer (current-buffer))))))
|
||||
|
||||
|
||||
;;; ein:shared-output-mode
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue