(defun s-repeat (num s) ;; extracted from s.el "Make a string of S repeated NUM times." (let (ss) (while (> num 0) (setq ss (cons s ss)) (setq num (1- num))) (apply 'concat ss))) (defun s-concat (&rest strings) ;; extracted from s.el "Join all the string arguments into one string." (apply 'concat strings)) (setq tee-program " import fcntl import os import select import sys fd = sys.stdin.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) filename, = sys.argv[1:] with open(filename, 'w') as stream: while True: select.select([sys.stdin], [], [sys.stdin], 0.2) data = sys.stdin.read() if data == '': break else: stream.write(data) stream.flush() ") (defun repro () (list (length (write-to-file (s-repeat 3000 "a"))) (length (write-to-file (s-repeat 5000 "a"))) (length (write-to-file (s-concat (s-repeat 3000 "a") "\n" (s-repeat 3000 "a")))) )) (defun write-to-file (input) (let (p) (if (not (file-exists-p "/tmp/bettertee.py")) (write-region tee-program nil "/tmp/bettertee.py")) (setq p (start-process "bocp" "*bocp*" "python" "/tmp/bettertee.py" "/tmp/line-repro-bug")) (process-send-string p input) (process-send-string p "\nnext") (process-send-eof p) (message (format "Waiting for process to die")) (while (process-live-p p) (sit-for 0.1)) (message "Process is dead") (get-string-from-file "/tmp/line-repro-bug") )) (defun get-string-from-file (filePath) "Return filePath's file content." (with-temp-buffer (insert-file-contents filePath) (buffer-string)))