From 75f5cb18169921774ed8aba585ea23af48db84c3 Mon Sep 17 00:00:00 2001 From: memeplex Date: Sun, 13 Oct 2019 19:16:53 -0300 Subject: [PATCH] Use native python fontification when sending input to shell (fix #1428) --- elpy-shell.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/elpy-shell.el b/elpy-shell.el index 6772ce696..e667fba34 100644 --- a/elpy-shell.el +++ b/elpy-shell.el @@ -519,8 +519,10 @@ complete). Otherwise, does nothing." (let ((from-point (point))) (insert string) (if (not no-font-lock) - (add-text-properties from-point (point) - (list 'front-sticky t 'font-lock-face face))))) + (if (eq face 'python-font-lock) + (python-shell-font-lock-post-command-hook) + (add-text-properties from-point (point) + (list 'front-sticky t 'font-lock-face face)))))) (defun elpy-shell--append-to-shell-output (string &optional no-font-lock prepend-cont-prompt) "Append the given STRING to the output of the Python shell buffer. @@ -540,7 +542,7 @@ Prepends a continuation promt if PREPEND-CONT-PROMPT is set." (lines (split-string string "\n"))) (goto-char mark-point) (elpy-shell--insert-and-font-lock - (car lines) 'comint-highlight-input no-font-lock) + (car lines) 'python-font-lock no-font-lock) (when (cdr lines) ;; no additional newline at end for multiline (dolist (line (cdr lines)) @@ -548,11 +550,11 @@ Prepends a continuation promt if PREPEND-CONT-PROMPT is set." (elpy-shell--insert-and-font-lock prompt 'comint-highlight-prompt no-font-lock) (elpy-shell--insert-and-font-lock - line 'comint-highlight-input no-font-lock))) + line 'python-font-lock no-font-lock))) ;; but put one for single line (insert "\n")) (elpy-shell--insert-and-font-lock - string 'comint-highlight-input no-font-lock)) + string 'python-font-lock no-font-lock)) (set-marker (process-mark process) (point))))))) (defun elpy-shell--string-head-lines (string n)