changeset 69527:64cdad743e23

(gud-gdb-complete-command, gud-gdb-run-command-fetch-lines): Adapt for use with watch expressions. (gud-tooltip-mode): Use buffer-local value.
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 16 Mar 2006 22:56:18 +0000
parents c32efda6ab27
children afd67a8ec176
files lisp/progmodes/gud.el
diffstat 1 files changed, 22 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gud.el	Thu Mar 16 22:55:00 2006 +0000
+++ b/lisp/progmodes/gud.el	Thu Mar 16 22:56:18 2006 +0000
@@ -740,14 +740,18 @@
 
 (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))))
@@ -866,13 +870,14 @@
 
 (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.
@@ -881,12 +886,13 @@
 	    (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)))))
 
 
@@ -3270,11 +3276,10 @@
     (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))