I'm using the following elisp snippet in a dedicated buffer to track progress of a wget
download.
(with-current-buffer buf
(setq proc
(apply 'start-process "my-download" buf
(list "wget" (if resume "-c" "") "-O" save-path url)))
....
)
This is great in that it gives me wget
's progress, but the problem is that the buffer isn't interpreting a control character the way I want. wget
sends a C-m
after every progress update, about once a second, because it is expecting to be connected to a vt100 and wants the cursor to return to the beginning of the current line, this so the next progress message will over-write the former one. The emacs buffer just inserts a literal C-m
and accumulates lines.
When I run wget
directly from an emacs ansi-term
buffer, the progress messages appear fine, so I tried looking in the code, but couldn't figure out what specifically was being done for C-m
interpretation. I did consider using an ansi-term
buffer for my program, but it wouldn't be appropriate because I'll be inserting other information and text there that aren't terminal commands. What I would like is a fundamental-mode
buffer modified to react to C-m
by performing a (forward-line 0)
.
term-emulate-terminal
. Keep in mind thatC-m
is represented as\r
, the carriage return. The function is used as process filter, so at the very least you'll want to write your own and apply it to the process.