+ (set-window-margins
+ window left-margin-width right-margin-width)))))
+
+\f
+;;; Functions for inline completion.
+
+(defvar gud-gdb-fetch-lines-in-progress)
+(defvar gud-gdb-fetch-lines-string)
+(defvar gud-gdb-fetch-lines-break)
+(defvar gud-gdb-fetched-lines)
+
+(defun gud-gdbmi-completions (context command)
+ "Completion table for GDB/MI commands.
+COMMAND is the prefix for which we seek completion.
+CONTEXT is the text before COMMAND on the line."
+ (let ((gud-gdb-fetch-lines-in-progress t)
+ (gud-gdb-fetch-lines-string nil)
+ (gud-gdb-fetch-lines-break (length context))
+ (gud-gdb-fetched-lines nil)
+ ;; This filter dumps output lines to `gud-gdb-fetched-lines'.
+ (gud-marker-filter #'gud-gdbmi-fetch-lines-filter)
+ complete-list)
+ (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
+ (gdb-input (concat "complete " context command)
+ (lambda () (setq gud-gdb-fetch-lines-in-progress nil)))
+ (while gud-gdb-fetch-lines-in-progress
+ (accept-process-output (get-buffer-process gud-comint-buffer))))
+ (gud-gdb-completions-1 gud-gdb-fetched-lines)))
+
+(defun gud-gdbmi-fetch-lines-filter (string)
+ "Custom filter function for `gud-gdbmi-completions'."
+ (setq string (concat gud-gdb-fetch-lines-string
+ (gud-gdbmi-marker-filter string)))
+ (while (string-match "\n" string)
+ (push (substring string gud-gdb-fetch-lines-break (match-beginning 0))
+ gud-gdb-fetched-lines)
+ (setq string (substring string (match-end 0))))
+ "")