- (if process
- (walk-windows
- (function (lambda (window)
- (if (eq (window-buffer window) current)
- (progn
- (select-window window)
- (if (and (< (point) (process-mark process))
- (or (eq scroll t) (eq scroll 'all)
- ;; Maybe user wants point to jump to the end.
- (and (eq scroll 'this) (eq selected window))
- (and (eq scroll 'others) (not (eq selected window)))
- ;; If point was at the end, keep it at the end.
- (>= (point)
- (- (process-mark process) (length string)))))
- (goto-char (process-mark process)))
- ;; Optionally scroll so that the text
- ;; ends at the bottom of the window.
- (if (and comint-scroll-show-maximum-output
- (>= (point) (process-mark process)))
- (save-excursion
- (goto-char (point-max))
- (recenter -1)))
- (select-window selected)))))
- nil t))))
+ (unwind-protect
+ (if process
+ (walk-windows
+ (function (lambda (window)
+ (if (eq (window-buffer window) current)
+ (progn
+ (select-window window)
+ (if (and (< (point) (process-mark process))
+ (or (eq scroll t) (eq scroll 'all)
+ ;; Maybe user wants point to jump to the end.
+ (and (eq scroll 'this) (eq selected window))
+ (and (eq scroll 'others) (not (eq selected window)))
+ ;; If point was at the end, keep it at the end.
+ (>= (point)
+ (- (process-mark process) (length string)))))
+ (goto-char (process-mark process)))
+ ;; Optionally scroll so that the text
+ ;; ends at the bottom of the window.
+ (if (and comint-scroll-show-maximum-output
+ (>= (point) (process-mark process)))
+ (save-excursion
+ (goto-char (point-max))
+ (recenter -1)))
+ (select-window selected)))))
+ nil t))
+ (set-buffer current))))