Function: gud-filter
gud-filter is a byte-compiled function defined in gud.el.gz.
Signature
(gud-filter PROC STRING)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; These functions are responsible for inserting output from your debugger
;; into the buffer. The hard work is done by the method that is
;; the value of gud-marker-filter.
(defun gud-filter (proc string)
;; Here's where the actual buffer insertion is done
(let (output process-window)
(if (buffer-name (process-buffer proc))
(if gud-filter-defer-flag
;; If we can't process any text now,
;; save it for later.
(setq gud-filter-pending-text
(concat (or gud-filter-pending-text "") string))
;; If we have to ask a question during the processing,
;; defer any additional text that comes from the debugger
;; during that time.
(let ((gud-filter-defer-flag t))
;; Process now any text we previously saved up.
(if gud-filter-pending-text
(setq string (concat gud-filter-pending-text string)
gud-filter-pending-text nil))
(with-current-buffer (process-buffer proc)
;; If we have been so requested, delete the debugger prompt.
(save-restriction
(widen)
(if (marker-buffer gud-delete-prompt-marker)
(let ((inhibit-read-only t))
(delete-region (process-mark proc)
gud-delete-prompt-marker)
(comint-update-fence)
(set-marker gud-delete-prompt-marker nil)))
;; Save the process output, checking for source file markers.
(setq output (gud-marker-filter string))
;; Check for a filename-and-line number.
;; Don't display the specified file
;; unless (1) point is at or after the position where output appears
;; and (2) this buffer is on the screen.
(setq process-window
(and gud-last-frame
(>= (point) (process-mark proc))
(get-buffer-window (current-buffer)))))
;; Let the comint filter do the actual insertion.
;; That lets us inherit various comint features.
(comint-output-filter proc output))
;; Put the arrow on the source line.
;; This must be outside of the save-excursion
;; in case the source file is our current buffer.
(if process-window
(with-selected-window process-window
(gud-display-frame))
;; We have to be in the proper buffer, (process-buffer proc),
;; but not in a save-excursion, because that would restore point.
(with-current-buffer (process-buffer proc)
(gud-display-frame))))
;; If we deferred text that arrived during this processing,
;; handle it now.
(if gud-filter-pending-text
(gud-filter proc ""))))))