jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

ANSI color sequences broken on emacs master since `ansi-color--find-face` was renamed

Open akirakyle opened this issue 3 years ago • 4 comments

I know there are already several other open and closed issues and an open PR around issues with ANSI color sequences. I'm opening this one since I suspect this is a separate issue from those that only occurs on emacs master.

Emacs commit 21dcb9830a renamed ansi-color--find-face to ansi-color--face-vec-face. Since that commit I see the following error:

Error during redisplay: (jit-lock-function 10140) signaled (void-function ansi-color--find-face)

Since errors during redisplay don't yield backtraces when debug-on-error is t, I manually ran (jupyter-org--ansi-color-apply-on-region (point-min) (point-max)) on an org buffer to get the backtrace

Debugger entered--Lisp error: (void-function ansi-color--find-face)
  ansi-color--find-face(nil)
  jupyter-ansi-color-apply-on-region(4925 4928)
  jupyter-org--ansi-color-apply-on-region(1 4928)
  #<subr eval-expression>((jupyter-org--ansi-color-apply-on-region (point-min) (point-max)) nil nil 127)
  apply(#<subr eval-expression> ((jupyter-org--ansi-color-apply-on-region (point-min) (point-max)) nil nil 127))
  eval-expression((jupyter-org--ansi-color-apply-on-region (point-min) (point-max)) nil nil 127)
  funcall-interactively(eval-expression (jupyter-org--ansi-color-apply-on-region (point-min) (point-max)) nil nil 127)
  command-execute(eval-expression)

akirakyle avatar Jan 15 '22 02:01 akirakyle

In trying to fix this for myself I found that since emacs commit 8700319109, ansi-color-apply-on-region supports an optional argument preserve-sequences which seems to mean that jupyter-ansi-color-apply-on-region is no longer necessary. When I redefine it to

(defun jupyter-ansi-color-apply-on-region (begin end)
  (ansi-color-apply-on-region begin end t))

ANSI color sequences work for me again. The only issue I see with the fix is that ANSI sequences in a results drawer do not seem to be fontified when an org file is first loaded, although they are correctly fontified after any modifications are made to the buffer.

akirakyle avatar Jan 17 '22 01:01 akirakyle

Thank you! I had this issue as well.

Tass0sm avatar Jan 22 '22 00:01 Tass0sm

Same here.

stardiviner avatar Mar 05 '22 03:03 stardiviner

Does not work in case of org-babel-execute-buffer, but the issue seems to be that jupyter-org-font-lock-ansi-escapes is not invoked at all in that case. Seems to work fine with org-ctrl-c-ctrl-c however.

Alexander-Shukaev avatar Sep 17 '22 18:09 Alexander-Shukaev

I'm experiencing this issue. I'm finding that redefining jupyter-ansi-color-apply-on-region is not working because when executing a cell with C-c C-c the function is redefined again to its original form.

UndeadKernel avatar Mar 07 '23 10:03 UndeadKernel

Finally, this issue is fixed. Regards.

stardiviner avatar May 09 '23 01:05 stardiviner

Finally, this issue is fixed. Regards.

It seems that the issue still exists when the output is put in the example block. Try the following code:

#+begin_src jupyter-R
library(tidyverse)
#+end_src

fountainer avatar May 09 '23 06:05 fountainer