Skip to content

Commit 841c2ff

Browse files
committed
Don't use font-lock-face when fontifying ANSI sequences in Org
Since `font-lock-face` is on the default value of `yank-excluded-properties`, it gets stripped when yanking so a different property is used to preserve the face of such sequences on yanks into regions where `jupyter-org--ansi-color-apply-on-region` is called.
1 parent eebeef1 commit 841c2ff

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

jupyter-mime.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,15 @@ function."
197197

198198
;;; Special handling of ANSI sequences
199199

200-
(defun jupyter-ansi-color-apply-on-region (begin end)
200+
(defun jupyter-ansi-color-apply-on-region (begin end &optional face-prop)
201201
"`ansi-color-apply-on-region' with Jupyter specific modifications.
202202
In particular, does not delete escape sequences between BEGIN and
203203
END from the buffer. Instead, an invisible text property with a
204204
value of t is added to render the escape sequences invisible.
205205
Also, the `ansi-color-apply-face-function' is hard-coded to a
206206
custom function that prepends to the face property of the text
207-
and also sets the font-lock-face to the prepended face.
207+
and also sets the FACE-PROP to the prepended face, if FACE-PROP
208+
is nil it defaults to `font-lock-face'.
208209
209210
For convenience, a jupyter-invisible property is also added with
210211
a value of t. This is mainly for modes like `org-mode' which
@@ -220,7 +221,7 @@ invisible property by adding it to `char-property-alias-alist'."
220221
(when face
221222
(setq face (list face))
222223
(font-lock-prepend-text-property beg end 'face face)
223-
(put-text-property beg end 'font-lock-face face)))))
224+
(put-text-property beg end (or face-prop 'font-lock-face) face)))))
224225
(save-excursion
225226
(goto-char start-marker)
226227
;; Find the next escape sequence.

jupyter-org-client.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,14 @@ property."
568568
begin next)
569569
(while (/= begin1 end1)
570570
(setq next (next-single-property-change
571-
begin1 'font-lock-face nil end1))
572-
(when (get-text-property begin1 'font-lock-face)
571+
begin1 'jupyter-face nil end1))
572+
(when (get-text-property begin1 'jupyter-face)
573573
(font-lock-prepend-text-property
574-
begin1 next 'face (get-text-property begin1 'font-lock-face)))
574+
begin1 next 'face (get-text-property begin1 'jupyter-face)))
575575
(setq begin1 next)))
576576
(t
577577
(put-text-property begin next 'jupyter-ansi t)
578-
(jupyter-ansi-color-apply-on-region begin next)
578+
(jupyter-ansi-color-apply-on-region begin next 'jupyter-face)
579579
(setq begin next))))))
580580

581581
;; Adapted from `org-fontify-meta-lines-and-blocks-1'

0 commit comments

Comments
 (0)