comparison lisp/progmodes/gud.el @ 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 1db3b0eac5a2
children 99bce5a59fbf e3bacb89536a
comparison
equal deleted inserted replaced
69526:c32efda6ab27 69527:64cdad743e23
738 ;; The completion list is constructed by the process filter. 738 ;; The completion list is constructed by the process filter.
739 (defvar gud-gdb-fetched-lines) 739 (defvar gud-gdb-fetched-lines)
740 740
741 (defvar gud-comint-buffer nil) 741 (defvar gud-comint-buffer nil)
742 742
743 (defun gud-gdb-complete-command () 743 (defun gud-gdb-complete-command (&optional command a b)
744 "Perform completion on the GDB command preceding point. 744 "Perform completion on the GDB command preceding point.
745 This is implemented using the GDB `complete' command which isn't 745 This is implemented using the GDB `complete' command which isn't
746 available with older versions of GDB." 746 available with older versions of GDB."
747 (interactive) 747 (interactive)
748 (let* ((end (point)) 748 (if command
749 (command (buffer-substring (comint-line-beginning-position) end)) 749 ;; Used by gud-watch in mini-buffer.
750 (command-word 750 (setq command (concat "p " command))
751 ;; Used in GUD buffer.
752 (let ((end (point)))
753 (setq command (buffer-substring (comint-line-beginning-position) end))))
754 (let* ((command-word
751 ;; Find the word break. This match will always succeed. 755 ;; Find the word break. This match will always succeed.
752 (and (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command) 756 (and (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command)
753 (substring command (match-beginning 2)))) 757 (substring command (match-beginning 2))))
754 (complete-list 758 (complete-list
755 (gud-gdb-run-command-fetch-lines (concat "complete " command) 759 (gud-gdb-run-command-fetch-lines (concat "complete " command)
864 ; "Learn GDB information for the currently selected stack frame in BUFFER." 868 ; "Learn GDB information for the currently selected stack frame in BUFFER."
865 ; ) 869 ; )
866 870
867 (defun gud-gdb-run-command-fetch-lines (command buffer &optional skip) 871 (defun gud-gdb-run-command-fetch-lines (command buffer &optional skip)
868 "Run COMMAND, and return the list of lines it outputs. 872 "Run COMMAND, and return the list of lines it outputs.
869 BUFFER is the GUD buffer in which to run the command. 873 BUFFER is the current buffer which may be the GUD buffer in which to run.
870 SKIP is the number of chars to skip on each lines, it defaults to 0." 874 SKIP is the number of chars to skip on each lines, it defaults to 0."
871 (with-current-buffer buffer 875 (with-current-buffer gud-comint-buffer
872 (if (save-excursion 876 (if (and (eq gud-comint-buffer buffer)
873 (goto-char (point-max)) 877 (save-excursion
874 (forward-line 0) 878 (goto-char (point-max))
875 (not (looking-at comint-prompt-regexp))) 879 (forward-line 0)
880 (not (looking-at comint-prompt-regexp))))
876 nil 881 nil
877 ;; Much of this copied from GDB complete, but I'm grabbing the stack 882 ;; Much of this copied from GDB complete, but I'm grabbing the stack
878 ;; frame instead. 883 ;; frame instead.
879 (let ((gud-gdb-fetch-lines-in-progress t) 884 (let ((gud-gdb-fetch-lines-in-progress t)
880 (gud-gdb-fetched-lines nil) 885 (gud-gdb-fetched-lines nil)
881 (gud-gdb-fetch-lines-string nil) 886 (gud-gdb-fetch-lines-string nil)
882 (gud-gdb-fetch-lines-break (or skip 0)) 887 (gud-gdb-fetch-lines-break (or skip 0))
883 (gud-marker-filter 888 (gud-marker-filter
884 `(lambda (string) (gud-gdb-fetch-lines-filter string ',gud-marker-filter)))) 889 `(lambda (string)
890 (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
885 ;; Issue the command to GDB. 891 ;; Issue the command to GDB.
886 (gud-basic-call command) 892 (gud-basic-call command)
887 ;; Slurp the output. 893 ;; Slurp the output.
888 (while gud-gdb-fetch-lines-in-progress 894 (while gud-gdb-fetch-lines-in-progress
889 (accept-process-output (get-buffer-process buffer))) 895 (accept-process-output (get-buffer-process gud-comint-buffer)))
890 (nreverse gud-gdb-fetched-lines))))) 896 (nreverse gud-gdb-fetched-lines)))))
891 897
892 898
893 ;; ====================================================================== 899 ;; ======================================================================
894 ;; sdb functions 900 ;; sdb functions
3268 (unless tooltip-mode (remove-hook 'pre-command-hook 'tooltip-hide) 3274 (unless tooltip-mode (remove-hook 'pre-command-hook 'tooltip-hide)
3269 (remove-hook 'change-major-mode-hook 'gud-tooltip-change-major-mode) 3275 (remove-hook 'change-major-mode-hook 'gud-tooltip-change-major-mode)
3270 (remove-hook 'tooltip-hook 'gud-tooltip-tips) 3276 (remove-hook 'tooltip-hook 'gud-tooltip-tips)
3271 (define-key global-map [mouse-movement] 'ignore))) 3277 (define-key global-map [mouse-movement] 'ignore)))
3272 (gud-tooltip-activate-mouse-motions-if-enabled) 3278 (gud-tooltip-activate-mouse-motions-if-enabled)
3273 (if (and 3279 (if (and gud-comint-buffer
3274 gud-comint-buffer 3280 (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
3275 (buffer-name gud-comint-buffer); gud-comint-buffer might be killed 3281 (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
3276 (with-current-buffer gud-comint-buffer 3282 '(gdbmi gdba)))
3277 (memq gud-minor-mode '(gdbmi gdba))))
3278 (if gud-tooltip-mode 3283 (if gud-tooltip-mode
3279 (progn 3284 (progn
3280 (dolist (buffer (buffer-list)) 3285 (dolist (buffer (buffer-list))
3281 (unless (eq buffer gud-comint-buffer) 3286 (unless (eq buffer gud-comint-buffer)
3282 (with-current-buffer buffer 3287 (with-current-buffer buffer