changeset 1256:ff24725192d3

* gud.el: When we send a command to the debugger via gud-call, it's annoying to see the command and the new prompt in the debugger interaction buffer; nuke the command and the old prompt. (gud-delete-prompt-marker): New variable, with extensive documentation. (gud-mode): Make gud-delete-prompt-marker buffer-local, and initialize it. (gud-filter-insert): If gud-delete-prompt-marker is set, delete the prompt, and clear gud-delete-prompt-marker. (gud-call): Arrange for the last prompt printed to get deleted, by setting gud-delete-prompt-char.
author Jim Blandy <jimb@redhat.com>
date Tue, 29 Sep 1992 09:57:12 +0000
parents ff06503c93b4
children e712192d20f5
files lisp/gud.el
diffstat 1 files changed, 60 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gud.el	Tue Sep 29 07:45:05 1992 +0000
+++ b/lisp/gud.el	Tue Sep 29 09:57:12 1992 +0000
@@ -282,6 +282,48 @@
 
 (defvar gud-command-queue nil)
 
+;;; When we send a command to the debugger via gud-call, it's annoying
+;;; to see the command and the new prompt inserted into the debugger's
+;;; buffer; we have other ways of knowing the command has completed.
+;;;
+;;; If the buffer looks like this:
+;;; --------------------
+;;; (gdb) set args foo bar
+;;; (gdb) -!-
+;;; --------------------
+;;; (the -!- marks the location of point), and we type `C-x SPC' in a
+;;; source file to set a breakpoint, we want the buffer to end up like
+;;; this:
+;;; --------------------
+;;; (gdb) set args foo bar
+;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49.
+;;; (gdb) -!-
+;;; --------------------
+;;; Essentially, the old prompt is deleted, and the command's output
+;;; and the new prompt take its place.
+;;;
+;;; Not echoing the command is easy enough; you send it directly using
+;;; process-send-string, and it never enters the buffer.  However,
+;;; getting rid of the old prompt is trickier; you don't want to do it
+;;; when you send the command, since that will result in an annoying
+;;; flicker as the prompt is deleted, redisplay occurs while Emacs
+;;; waits for a response from the debugger, and the new prompt is
+;;; inserted.  Instead, we'll wait until we actually get some output
+;;; from the subprocess before we delete the prompt.  If the command
+;;; produced no output other than a new prompt, that prompt will most
+;;; likely be in the first chunk of output received, so we will delete
+;;; the prompt and then replace it with an identical one.  If the
+;;; command produces output, the prompt is moving anyway, so the
+;;; flicker won't be annoying.
+;;;
+;;; So - when we want to delete the prompt upon receipt of the next
+;;; chunk of debugger output, we position gud-delete-prompt-marker at
+;;; the start of the prompt; the process filter will notice this, and
+;;; delete all text between it and the process output marker.  If
+;;; gud-delete-prompt-marker points nowhere, we leave the current
+;;; prompt alone.
+(defvar gud-delete-prompt-marker nil)
+
 (if gud-mode-map
    nil
   (setq gud-mode-map (copy-keymap comint-mode-map))
@@ -348,6 +390,8 @@
   (make-local-variable 'gud-last-frame)
   (setq gud-last-frame nil)
   (make-local-variable 'comint-prompt-regexp)
+  (make-local-variable 'gud-delete-prompt-marker)
+  (setq gud-delete-prompt-marker (make-marker))
   (run-hooks 'gud-mode-hook)
 )
 
@@ -396,8 +440,12 @@
   (save-excursion
     (set-buffer (process-buffer proc))
     (let ((output-after-point (< (point) (process-mark proc))))
-      ;; Insert the text, moving the process-marker.
       (goto-char (process-mark proc))
+      ;; If we have been so requested, delete the debugger prompt.
+      (if (marker-buffer gud-delete-prompt-marker)
+	  (progn
+	    (delete-region (point) gud-delete-prompt-marker)
+	    (set-marker gud-delete-prompt-marker nil)))
       (insert-before-markers string)
       ;; Check for a filename-and-line number.
       ;; Don't display the specified file
@@ -487,12 +535,19 @@
   "Invoke the debugger COMMAND displaying source in other window."
   (interactive)
   (gud-set-buffer)
-  (goto-char (point-max))
   (let ((command (concat (apply 'format command args) "\n"))
 	(proc (get-buffer-process current-gud-buffer)))
-    (gud-filter-insert proc command)
-    (send-string proc command)
-    ))
+
+    ;; Arrange for the current prompt to get deleted.
+    (save-excursion
+      (set-buffer current-gud-buffer)
+      (goto-char (process-marker proc))
+      (beginning-of-line)
+      (if (looking-at comint-prompt-regexp)
+	  (set-marker gud-delete-prompt-marker (point))))
+
+    (goto-char (point-max))
+    (process-send-string proc command)))
 
 (defun gud-queue-send (&rest cmdlist)
   ;; Send the first command, queue the rest for send after successive