(defvar gud-comint-buffer nil)
-(defun gud-gdb-complete-command ()
+(defun gud-gdb-complete-command (&optional command a b)
"Perform completion on the GDB command preceding point.
This is implemented using the GDB `complete' command which isn't
available with older versions of GDB."
(interactive)
- (let* ((end (point))
- (command (buffer-substring (comint-line-beginning-position) end))
- (command-word
+ (if command
+ ;; Used by gud-watch in mini-buffer.
+ (setq command (concat "p " command))
+ ;; Used in GUD buffer.
+ (let ((end (point)))
+ (setq command (buffer-substring (comint-line-beginning-position) end))))
+ (let* ((command-word
;; Find the word break. This match will always succeed.
(and (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command)
(substring command (match-beginning 2))))
(defun gud-gdb-run-command-fetch-lines (command buffer &optional skip)
"Run COMMAND, and return the list of lines it outputs.
-BUFFER is the GUD buffer in which to run the command.
+BUFFER is the current buffer which may be the GUD buffer in which to run.
SKIP is the number of chars to skip on each lines, it defaults to 0."
- (with-current-buffer buffer
- (if (save-excursion
- (goto-char (point-max))
- (forward-line 0)
- (not (looking-at comint-prompt-regexp)))
+ (with-current-buffer gud-comint-buffer
+ (if (and (eq gud-comint-buffer buffer)
+ (save-excursion
+ (goto-char (point-max))
+ (forward-line 0)
+ (not (looking-at comint-prompt-regexp))))
nil
;; Much of this copied from GDB complete, but I'm grabbing the stack
;; frame instead.
(gud-gdb-fetch-lines-string nil)
(gud-gdb-fetch-lines-break (or skip 0))
(gud-marker-filter
- `(lambda (string) (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
+ `(lambda (string)
+ (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
;; Issue the command to GDB.
(gud-basic-call command)
;; Slurp the output.
(while gud-gdb-fetch-lines-in-progress
- (accept-process-output (get-buffer-process buffer)))
+ (accept-process-output (get-buffer-process gud-comint-buffer)))
(nreverse gud-gdb-fetched-lines)))))
\f
(remove-hook 'tooltip-hook 'gud-tooltip-tips)
(define-key global-map [mouse-movement] 'ignore)))
(gud-tooltip-activate-mouse-motions-if-enabled)
- (if (and
- gud-comint-buffer
- (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
- (with-current-buffer gud-comint-buffer
- (memq gud-minor-mode '(gdbmi gdba))))
+ (if (and gud-comint-buffer
+ (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
+ (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba)))
(if gud-tooltip-mode
(progn
(dolist (buffer (buffer-list))