home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!traffic!kevin
- From: kevin@traffic.den.mmc.com (Kevin Rodgers)
- Newsgroups: gnu.emacs.help
- Subject: Re: Help with gdb-4.6 and gdb-mode (Command-completion with TAB)
- Message-ID: <1992Jul23.211418.939@den.mmc.com>
- Date: 23 Jul 92 21:14:18 GMT
- References: <ROLF.92Jul17164511@green.mathematik.uni-stuttgart.de>
- Sender: news@den.mmc.com (News)
- Organization: Martin Marietta Western Internal Systems, Technical Operations
- Lines: 106
- Nntp-Posting-Host: traffic.den.mmc.com
-
- In article <ROLF.92Jul17164511@green.mathematik.uni-stuttgart.de> rolf@green.mathematik.uni-stuttgart.de (Rolf Schreiber) writes:
- >With gdb-4.6 you can use command-completion on c++ function names.
- >This seems to be very useful, but is done with TAB, TAB-TAB and ESC-?,
- >which all don't pass through emacs-gdb-mode.
- >
- >So could anybody help me, what to change in gdb-mode.el or my .emacs
- >file, so I can use this feature of gdb?
-
- I investigated gdb.el and shell.el, and this is the best I could come up
- with. See the note on comint-gdb.el and comint.el, and don't forget to
- delete my .sig from the end of this article. [This will also appear
- soon in gnu.emacs.sources.]
-
- ;;;; gdb-completion.el
-
- ;;;; Enable TAB, TAB-TAB, and ESC-? Gdb command completion.
-
- ;;; Notes:
-
- ;; 1. This depends upon comint-gdb.el by Mike Williams
- ;; <mike-w@cs.aukuni.ac.nz>, which in turn depends upon comint.el by
- ;; Olin Shivers <Olin.Shivers@cs.cmu.edu>. Both of these are
- ;; available via anonymous ftp from
- ;; cs.cmu.edu:/afs/cs.cmu.edu/user/shivers/lib/emacs/.
-
- ;; 2. To use gdb-completion, add these to your ~/.emacs file:
- ;; (autoload (function gdb) "comint-gdb"
- ;; "Major mode for interacting with an inferior Gdb process..." t)
- ;; (setq gdb-load-hook
- ;; (function (lambda ()
- ;; (require 'gdb-completion))))
-
- ;;; Bugs:
-
- ;; 1. After a single TAB has been sent to the inferior Gdb process, the
- ;; process may ring the bell by writing \a (i.e. C-g) on its standard
- ;; error. However, process filters only read from the standard
- ;; output, so gdb-filter never detects the \a.
-
- ;; 2. After two TABs or ESC ? have been sent to the inferior Gdb
- ;; process, the process filter reads the completions, but doesn't see
- ;; the echoed incomplete command line which should follow as a
- ;; prompt. I don't know why this is, since it doesn't seem to be
- ;; written on the standard error.
-
-
- ;;; Gdb completion commands:
-
- (defun gdb-complete ()
- "*Complete Gdb command if unique, or display all possible completions
- when typed twice in a row."
- (interactive)
- (gdb-send-incomplete "\t"))
-
- (defun gdb-display-completions ()
- "*Display all possible Gdb command completions."
- (interactive)
- (gdb-send-incomplete "\e?"))
-
- (defun gdb-send-incomplete (completion)
- "Send input to inferior Gdb process, with COMPLETION string appended
- instead of newline."
- (let ((comint-input-sender (function
- (lambda (proc string)
- ;; delete newline from buffer:
- (backward-delete-char 1)
- ;; send input to Gdb:
- (comint-send-string proc string)
- (comint-send-string proc completion)))))
- (comint-send-input)))
-
-
- ;;; Bind the Gdb completion commands:
-
- (define-key gdb-mode-map "\t" (function gdb-complete))
- (define-key gdb-mode-map "\M-?" (function gdb-display-completions))
-
-
- ;;; Modify the process output filter:
-
- (fset 'original-gdb-filter (symbol-function 'gdb-filter))
-
- (defun gdb-filter (proc string)
- (let ((match-data (match-data))
- (prev-point-max (point-max)))
- (funcall (function original-gdb-filter) proc string)
- (unwind-protect
- (save-excursion
- (goto-char prev-point-max)
- (forward-line -1)
- (while (or (search-forward "\^M" (point-max) t)
- (let ((alarm (search-forward "\a" (point-max) t)))
- (if alarm (beep t))
- alarm))
- (replace-match "")))
- (store-match-data match-data))))
-
-
- ;;; Advertise the provided feature:
-
- (provide 'gdb-completion)
- --
- Kevin Rodgers kevin@traffic.den.mmc.com
- Martin Marietta MS A16401 (303) 790-3971
- 116 Inverness Dr. East
- Englewood CO 80112 USA GO BUFFS!
-