Skip to content

Commit 75f5cb1

Browse files
committed
Use native python fontification when sending input to shell (fix #1428)
1 parent 7e4dd5d commit 75f5cb1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

elpy-shell.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ complete). Otherwise, does nothing."
519519
(let ((from-point (point)))
520520
(insert string)
521521
(if (not no-font-lock)
522-
(add-text-properties from-point (point)
523-
(list 'front-sticky t 'font-lock-face face)))))
522+
(if (eq face 'python-font-lock)
523+
(python-shell-font-lock-post-command-hook)
524+
(add-text-properties from-point (point)
525+
(list 'front-sticky t 'font-lock-face face))))))
524526

525527
(defun elpy-shell--append-to-shell-output (string &optional no-font-lock prepend-cont-prompt)
526528
"Append the given STRING to the output of the Python shell buffer.
@@ -540,19 +542,19 @@ Prepends a continuation promt if PREPEND-CONT-PROMPT is set."
540542
(lines (split-string string "\n")))
541543
(goto-char mark-point)
542544
(elpy-shell--insert-and-font-lock
543-
(car lines) 'comint-highlight-input no-font-lock)
545+
(car lines) 'python-font-lock no-font-lock)
544546
(when (cdr lines)
545547
;; no additional newline at end for multiline
546548
(dolist (line (cdr lines))
547549
(insert "\n")
548550
(elpy-shell--insert-and-font-lock
549551
prompt 'comint-highlight-prompt no-font-lock)
550552
(elpy-shell--insert-and-font-lock
551-
line 'comint-highlight-input no-font-lock)))
553+
line 'python-font-lock no-font-lock)))
552554
;; but put one for single line
553555
(insert "\n"))
554556
(elpy-shell--insert-and-font-lock
555-
string 'comint-highlight-input no-font-lock))
557+
string 'python-font-lock no-font-lock))
556558
(set-marker (process-mark process) (point)))))))
557559

558560
(defun elpy-shell--string-head-lines (string n)

0 commit comments

Comments
 (0)