changeset 70248:4fc61ee2deb2

(gud-comint-buffer): Move forward to stop byte compiler warnings. (gud-basic-call, gud-find-expr): Let user select an expression for printing. Print expression as well as value in GUD buffer.
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 26 Apr 2006 23:03:56 +0000
parents 039ae41bde1a
children eb2b6bd1c6f0
files lisp/progmodes/gud.el
diffstat 1 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gud.el	Wed Apr 26 23:02:33 2006 +0000
+++ b/lisp/progmodes/gud.el	Wed Apr 26 23:03:56 2006 +0000
@@ -83,6 +83,8 @@
 (defvar gud-minor-mode nil)
 (put 'gud-minor-mode 'permanent-local t)
 
+(defvar gud-comint-buffer nil)
+
 (defvar gud-keep-buffer nil)
 
 (defun gud-symbol (sym &optional soft minor-mode)
@@ -740,8 +742,6 @@
 ;; The completion list is constructed by the process filter.
 (defvar gud-gdb-fetched-lines)
 
-(defvar gud-comint-buffer nil)
-
 (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
@@ -2889,8 +2889,11 @@
       (set-buffer gud-comint-buffer)
       (save-restriction
 	(widen)
-	(goto-char (process-mark proc))
-	(forward-line 0)
+	(if (marker-position gud-delete-prompt-marker)
+	    ;; We get here when printing an expression.
+	    (goto-char gud-delete-prompt-marker)
+	  (goto-char (process-mark proc))
+	  (forward-line 0))
 	(if (looking-at comint-prompt-regexp)
 	    (set-marker gud-delete-prompt-marker (point)))
 	(if (memq gud-minor-mode '(gdbmi gdba))
@@ -2911,7 +2914,21 @@
 (defvar gud-find-expr-function 'gud-find-c-expr)
 
 (defun gud-find-expr (&rest args)
-  (apply gud-find-expr-function args))
+  (let ((expr (if (and transient-mark-mode mark-active)
+		  (buffer-substring (region-beginning) (region-end))
+		(apply gud-find-expr-function args))))
+    (save-match-data
+      (if (string-match "\n" expr)
+	  (error "Expression must not include a newline"))
+      (with-current-buffer gud-comint-buffer
+	(save-excursion
+	  (goto-char (process-mark (get-buffer-process gud-comint-buffer)))
+	  (forward-line 0)
+	  (when (looking-at comint-prompt-regexp)
+	    (set-marker gud-delete-prompt-marker (point))
+	    (set-marker-insertion-type gud-delete-prompt-marker t))
+	  (insert (concat  expr " = ")))))
+    expr))
 
 ;; The next eight functions are hacked from gdbsrc.el by
 ;; Debby Ayers <ayers@asc.slb.com>,