[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inferior Python mode doesn't fontify correctly
From: |
Stefan Monnier |
Subject: |
Re: Inferior Python mode doesn't fontify correctly |
Date: |
Tue, 14 Nov 2006 10:32:06 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (gnu/linux) |
> M-x run-python RET
> import os RET
> help(os) RET
> Fontification gets very confused when, for example, single quotes are
> used as apostrophes rather than delimiting strings. It makes the
> output really difficult to read.
Indeed, using the programming language's syntax-table for the inferior
process's buffer is often a bad idea since that buffer mixes code with
arbitrary program output.
The patch below tries to fix just this one case you complain about, but
maybe we should go a few steps further?
Stefan
--- python.el 25 oct 2006 01:34:35 -0400 1.50
+++ python.el 14 nov 2006 10:29:15 -0500
@@ -1194,6 +1194,15 @@
;; (define-key map "\C-c\C-f" 'python-describe-symbol)
map))
+(defvar inferior-python-mode-syntax-table
+ (let ((st (make-syntax-table python-mode-syntax-table)))
+ ;; Don't get confused by apostrophes in the process's output (e.g. if
+ ;; you execute "help(os)").
+ (modify-syntax-entry ?\' "." st)
+ ;; Maybe we should do the same for double quotes?
+ ;; (modify-syntax-entry ?\" "." st)
+ st))
+
;; Fixme: This should inherit some stuff from `python-mode', but I'm
;; not sure how much: at least some keybindings, like C-c C-f;
;; syntax?; font-locking, e.g. for triple-quoted strings?
@@ -1216,7 +1225,6 @@
\\{inferior-python-mode-map}"
:group 'python
- (set-syntax-table python-mode-syntax-table)
(setq mode-line-process '(":%s"))
(set (make-local-variable 'comint-input-filter) 'python-input-filter)
(add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter