diff options
| author | Jim Blandy | 1992-09-29 09:57:12 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-09-29 09:57:12 +0000 |
| commit | 53eb3a97fb00ff97a43d98f40d97726df792c73a (patch) | |
| tree | 5a6390427355da4012e2cbed804a933fce123704 | |
| parent | 6bde8427201e9c8c034f2851f644524396321cfa (diff) | |
| download | emacs-53eb3a97fb00ff97a43d98f40d97726df792c73a.tar.gz emacs-53eb3a97fb00ff97a43d98f40d97726df792c73a.zip | |
* 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.
| -rw-r--r-- | lisp/gud.el | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 5425d3a6dad..b7435f460d5 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -282,6 +282,48 @@ It is for customization by you.") | |||
| 282 | 282 | ||
| 283 | (defvar gud-command-queue nil) | 283 | (defvar gud-command-queue nil) |
| 284 | 284 | ||
| 285 | ;;; When we send a command to the debugger via gud-call, it's annoying | ||
| 286 | ;;; to see the command and the new prompt inserted into the debugger's | ||
| 287 | ;;; buffer; we have other ways of knowing the command has completed. | ||
| 288 | ;;; | ||
| 289 | ;;; If the buffer looks like this: | ||
| 290 | ;;; -------------------- | ||
| 291 | ;;; (gdb) set args foo bar | ||
| 292 | ;;; (gdb) -!- | ||
| 293 | ;;; -------------------- | ||
| 294 | ;;; (the -!- marks the location of point), and we type `C-x SPC' in a | ||
| 295 | ;;; source file to set a breakpoint, we want the buffer to end up like | ||
| 296 | ;;; this: | ||
| 297 | ;;; -------------------- | ||
| 298 | ;;; (gdb) set args foo bar | ||
| 299 | ;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49. | ||
| 300 | ;;; (gdb) -!- | ||
| 301 | ;;; -------------------- | ||
| 302 | ;;; Essentially, the old prompt is deleted, and the command's output | ||
| 303 | ;;; and the new prompt take its place. | ||
| 304 | ;;; | ||
| 305 | ;;; Not echoing the command is easy enough; you send it directly using | ||
| 306 | ;;; process-send-string, and it never enters the buffer. However, | ||
| 307 | ;;; getting rid of the old prompt is trickier; you don't want to do it | ||
| 308 | ;;; when you send the command, since that will result in an annoying | ||
| 309 | ;;; flicker as the prompt is deleted, redisplay occurs while Emacs | ||
| 310 | ;;; waits for a response from the debugger, and the new prompt is | ||
| 311 | ;;; inserted. Instead, we'll wait until we actually get some output | ||
| 312 | ;;; from the subprocess before we delete the prompt. If the command | ||
| 313 | ;;; produced no output other than a new prompt, that prompt will most | ||
| 314 | ;;; likely be in the first chunk of output received, so we will delete | ||
| 315 | ;;; the prompt and then replace it with an identical one. If the | ||
| 316 | ;;; command produces output, the prompt is moving anyway, so the | ||
| 317 | ;;; flicker won't be annoying. | ||
| 318 | ;;; | ||
| 319 | ;;; So - when we want to delete the prompt upon receipt of the next | ||
| 320 | ;;; chunk of debugger output, we position gud-delete-prompt-marker at | ||
| 321 | ;;; the start of the prompt; the process filter will notice this, and | ||
| 322 | ;;; delete all text between it and the process output marker. If | ||
| 323 | ;;; gud-delete-prompt-marker points nowhere, we leave the current | ||
| 324 | ;;; prompt alone. | ||
| 325 | (defvar gud-delete-prompt-marker nil) | ||
| 326 | |||
| 285 | (if gud-mode-map | 327 | (if gud-mode-map |
| 286 | nil | 328 | nil |
| 287 | (setq gud-mode-map (copy-keymap comint-mode-map)) | 329 | (setq gud-mode-map (copy-keymap comint-mode-map)) |
| @@ -348,6 +390,8 @@ comint mode, which see." | |||
| 348 | (make-local-variable 'gud-last-frame) | 390 | (make-local-variable 'gud-last-frame) |
| 349 | (setq gud-last-frame nil) | 391 | (setq gud-last-frame nil) |
| 350 | (make-local-variable 'comint-prompt-regexp) | 392 | (make-local-variable 'comint-prompt-regexp) |
| 393 | (make-local-variable 'gud-delete-prompt-marker) | ||
| 394 | (setq gud-delete-prompt-marker (make-marker)) | ||
| 351 | (run-hooks 'gud-mode-hook) | 395 | (run-hooks 'gud-mode-hook) |
| 352 | ) | 396 | ) |
| 353 | 397 | ||
| @@ -396,8 +440,12 @@ comint mode, which see." | |||
| 396 | (save-excursion | 440 | (save-excursion |
| 397 | (set-buffer (process-buffer proc)) | 441 | (set-buffer (process-buffer proc)) |
| 398 | (let ((output-after-point (< (point) (process-mark proc)))) | 442 | (let ((output-after-point (< (point) (process-mark proc)))) |
| 399 | ;; Insert the text, moving the process-marker. | ||
| 400 | (goto-char (process-mark proc)) | 443 | (goto-char (process-mark proc)) |
| 444 | ;; If we have been so requested, delete the debugger prompt. | ||
| 445 | (if (marker-buffer gud-delete-prompt-marker) | ||
| 446 | (progn | ||
| 447 | (delete-region (point) gud-delete-prompt-marker) | ||
| 448 | (set-marker gud-delete-prompt-marker nil))) | ||
| 401 | (insert-before-markers string) | 449 | (insert-before-markers string) |
| 402 | ;; Check for a filename-and-line number. | 450 | ;; Check for a filename-and-line number. |
| 403 | ;; Don't display the specified file | 451 | ;; Don't display the specified file |
| @@ -487,12 +535,19 @@ Obeying it means displaying in another window the specified file and line." | |||
| 487 | "Invoke the debugger COMMAND displaying source in other window." | 535 | "Invoke the debugger COMMAND displaying source in other window." |
| 488 | (interactive) | 536 | (interactive) |
| 489 | (gud-set-buffer) | 537 | (gud-set-buffer) |
| 490 | (goto-char (point-max)) | ||
| 491 | (let ((command (concat (apply 'format command args) "\n")) | 538 | (let ((command (concat (apply 'format command args) "\n")) |
| 492 | (proc (get-buffer-process current-gud-buffer))) | 539 | (proc (get-buffer-process current-gud-buffer))) |
| 493 | (gud-filter-insert proc command) | 540 | |
| 494 | (send-string proc command) | 541 | ;; Arrange for the current prompt to get deleted. |
| 495 | )) | 542 | (save-excursion |
| 543 | (set-buffer current-gud-buffer) | ||
| 544 | (goto-char (process-marker proc)) | ||
| 545 | (beginning-of-line) | ||
| 546 | (if (looking-at comint-prompt-regexp) | ||
| 547 | (set-marker gud-delete-prompt-marker (point)))) | ||
| 548 | |||
| 549 | (goto-char (point-max)) | ||
| 550 | (process-send-string proc command))) | ||
| 496 | 551 | ||
| 497 | (defun gud-queue-send (&rest cmdlist) | 552 | (defun gud-queue-send (&rest cmdlist) |
| 498 | ;; Send the first command, queue the rest for send after successive | 553 | ;; Send the first command, queue the rest for send after successive |