Skip to content

Commit

Permalink
Distribute ansi-color-apply
Browse files Browse the repository at this point in the history
  • Loading branch information
dickmao committed Oct 28, 2020
1 parent c77706c commit bf1ca5b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lisp/ein-cell.el
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ Called from ewoc pretty printer via `ein:cell-insert-output'."
(ein:log 'warn "ein:cell-append-mime-type: %s"
"no viewer method found in mailcap")))))
(ein:log 'warn "ein:cell-append-mime-type: %s not supported" type)))
((:text/plain)
(ein:insert-read-only (ansi-color-apply value)))
(otherwise
(ein:insert-read-only value)))))

Expand Down
5 changes: 1 addition & 4 deletions lisp/ein-dev.el
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ for debugger is hard-coded. See `debugger-setup-buffer'."
(interactive)
(message (concat "debug-on-error=%s websocket-debug=%s "
"websocket-callback-debug-on-error=%s "
"ein:debug=%s ein:log-level=%s ein:log-message-level=%s")
"ein:log-level=%s ein:log-message-level=%s")
debug-on-error websocket-debug websocket-callback-debug-on-error
ein:debug
(ein:log-level-int-to-name ein:log-level)
(ein:log-level-int-to-name ein:log-message-level)))

Expand Down Expand Up @@ -132,7 +131,6 @@ callback (`websocket-callback-debug-on-error') is enabled."
(setq request-message-level (quote verbose))
(setq websocket-debug t)
(setq websocket-callback-debug-on-error t)
(setq ein:debug t)
(ein:log-set-level 'debug)
(ein:log-set-message-level 'verbose)
(ein:dev-patch-backtrace)
Expand All @@ -149,7 +147,6 @@ callback (`websocket-callback-debug-on-error') is enabled."
(setq request-log-level -1)
(setq request-message-level 'warn)
(setq websocket-callback-debug-on-error nil)
(setq ein:debug nil)
(ein:log-set-level 'verbose)
(ein:log-set-message-level 'info)
(ein:dev-depatch-backtrace)
Expand Down
2 changes: 1 addition & 1 deletion lisp/ein-jupyter.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ with the call to the jupyter notebook."
(convert-standard-filename dir)))
args
(let ((copy (cl-copy-list ein:jupyter-server-args)))
(when ein:debug
(when (ein:debug-p)
(cl-pushnew "--debug" copy))
copy)))))
(proc (apply #'start-process
Expand Down
10 changes: 6 additions & 4 deletions lisp/ein-log.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@
(when (<= level ein:log-message-level)
(message "ein: %s" (ein:log-strip-timestamp msg))))))

(make-obsolete-variable 'ein:debug nil "0.17.0")

(defmacro ein:log (level string &rest args)
(declare (indent 1))
`(ein:log-wrapper ,level (lambda () (format ,string ,@args))))

;; FIXME: this variable must go to somewhere more central
(defvar ein:debug nil
(defsubst ein:debug-p ()
"Set to non-`nil' to raise errors instead of suppressing it.
Change the behavior of `ein:log-ignore-errors'.")
Change the behavior of `ein:log-ignore-errors'."
(>= ein:log-level (alist-get 'debug ein:log-level-def)))

(defmacro ein:log-ignore-errors (&rest body)
"Execute BODY; if an error occurs, log the error and return nil.
Otherwise, return result of last form in BODY."
(declare (debug t) (indent 0))
`(if ein:debug
`(if (ein:debug-p)
(progn ,@body)
(condition-case err
(progn ,@body)
Expand Down
3 changes: 1 addition & 2 deletions lisp/ein-worksheet.el
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ Unshift in list parlance means prepending to list."
(ein:worksheet-insert-cell-below ws 'code nil t))))
(set-buffer-modified-p nil)
(ein:worksheet-bind-events ws)
(ein:worksheet-set-kernel ws)
(ein:log 'info "Worksheet %s is ready" (ein:worksheet-notebook-path ws))))
(ein:worksheet-set-kernel ws)))

(defun ein:worksheet-pp (ewoc-data)
"Consider disabling `buffer-undo-list' here instead of `ein:cell--ewoc-invalidate'
Expand Down
2 changes: 1 addition & 1 deletion lisp/ob-ein.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
(outputs (cl-loop for out in (ein:oref-safe cell 'outputs)
collect (funcall render out))))
(when outputs
(ein:join-str "" outputs))))
(ansi-color-apply (ein:join-str "" outputs)))))

(defun ob-ein--get-name-create (src-block-info)
"Get the name of a src block or add a uuid as the name."
Expand Down

0 comments on commit bf1ca5b

Please sign in to comment.