Skip to content

Carriage return handling in process buffer #13

@shader

Description

@shader

I just started to use mbsync.el for automating the fetch+reload process with gnus; thanks for your work.

When running mbsync, the sync process spits out progress update lines ending with ^M to overwrite the output, but the simple process buffer currently just concatenates them with literal "^M" characters instead.

I found this code snippet on SO for a process filter that handles carriage returns:

;Fill the buffer in the same way as it would be shown in bash
(defun shelllike-filter (proc string)
  (let* ((buffer (process-buffer proc))
         (window (get-buffer-window buffer)))
    (with-current-buffer buffer
      (if (not (mark)) (push-mark))
      (exchange-point-and-mark) ;Use the mark to represent the cursor location
      (dolist (char (append string nil))
    (cond ((char-equal char ?\r)
           (move-beginning-of-line 1))
          ((char-equal char ?\n)
           (move-end-of-line 1) (newline))
          (t
           (if (/= (point) (point-max)) ;Overwrite character
           (delete-char 1))
           (insert char))))
      (exchange-point-and-mark))
    (if window
      (with-selected-window window
        (goto-char (point-max))))))

Could something like that be integrated into mbsync.el's process filter for cleaner output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions