Mercurial > emacs
comparison lisp/gud.el @ 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 |
comparison
equal
deleted
inserted
replaced
1255:ff06503c93b4 | 1256:ff24725192d3 |
---|---|
280 "List of strings or functions used by send-gud-command. | 280 "List of strings or functions used by send-gud-command. |
281 It is for customization by you.") | 281 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)) |
288 (define-key gud-mode-map "\C-c\C-l" 'gud-refresh)) | 330 (define-key gud-mode-map "\C-c\C-l" 'gud-refresh)) |
289 | 331 |
346 (setq mode-line-process '(": %s")) | 388 (setq mode-line-process '(": %s")) |
347 (use-local-map gud-mode-map) | 389 (use-local-map gud-mode-map) |
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 |
354 (defvar current-gud-buffer nil) | 398 (defvar current-gud-buffer nil) |
355 | 399 |
394 (defun gud-filter-insert (proc string) | 438 (defun gud-filter-insert (proc string) |
395 ;; Here's where the actual buffer insertion is done | 439 ;; Here's where the actual buffer insertion is done |
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 |
404 ;; unless (1) point is at or after the position where output appears | 452 ;; unless (1) point is at or after the position where output appears |
405 ;; and (2) this buffer is on the screen. | 453 ;; and (2) this buffer is on the screen. |
485 | 533 |
486 (defun gud-call (command &rest args) | 534 (defun gud-call (command &rest args) |
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 |
499 ;; send on subsequent prompts | 554 ;; send on subsequent prompts |
500 (interactive) | 555 (interactive) |