unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47657: python-shell font-lock with multi-line input: runaway fontification buffer length
@ 2021-04-08 15:48 JD Smith
  2021-04-12  9:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: JD Smith @ 2021-04-08 15:48 UTC (permalink / raw)
  To: 47657

[-- Attachment #1: Type: text/plain, Size: 9231 bytes --]

	
`python-shell-font-lock-post-command-hook’ makes the presumption that only a single line of input can appear at the prompt.  It includes this preparatory “clean-up” of its font lock buffer after first having copied all input lines after the prompt:

      (let* ((input (buffer-substring-no-properties
                     prompt-end (point-max)))
           ...
             (replacement
              (python-shell-font-lock-with-font-lock-buffer
                (delete-region (line-beginning-position)
                               (point-max))
                (setq font-lock-buffer-pos (point))
                (insert input)


This means that using, e.g., C-c SPC (`comint-accumulate’) to insert a newline at the shell prompt leads to runaway growth of the font-lock buffer (“ *Python-font-lock”, by default).  Any command, like an insert, produces a new copy of all but the final line of input in this buffer.  Since this entire buffer is font-locked from scratch after every single command, this becomes very inefficient.  

Find an example, below.

The simple fix would be to delete the entire font-lock buffer file contents:

	(delete-region (point-min) (point-max))

A perhaps smarter and more efficient fix would be to enable font locking in the inferior Python buffer itself, but constrain it to the text after the process mark.  This would also prevent front-lock from constantly having to re-fontify the entire input text after each command. 

++++

(In *Python* shell buffer):

In [2]: a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
d='and I’ 

(In " *Python-font-lock"; this can become arbitrarily long):

a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
a= 'now is the time'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
a= 'now is the time'
for i in range(12):
a = 12; print(i+4-4) 
b='one two one two and through and through'
d='and I' 

[-- Attachment #2: Type: text/html, Size: 49654 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-13 16:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 15:48 bug#47657: python-shell font-lock with multi-line input: runaway fontification buffer length JD Smith
2021-04-12  9:32 ` Lars Ingebrigtsen
2021-04-12 13:18   ` JD Smith
2021-04-13  8:05     ` Lars Ingebrigtsen
2021-04-13 13:14       ` JD Smith
2021-04-25 17:34         ` Lars Ingebrigtsen
2021-04-25 17:53           ` JD Smith
2021-04-25 19:19             ` Lars Ingebrigtsen
2021-10-13 16:45               ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).