home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.sources
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevin
- From: kevin@traffic.den.mmc.com (Kevin Rodgers)
- Subject: gdb-completion.el
- Message-ID: <9207232118.AA24304@traffic>
- Sender: daemon@cis.ohio-state.edu
- Reply-To: kevin@traffic.den.mmc.com
- Organization: Source only Discussion and requests in gnu.emacs.help.
- Distribution: gnu
- Date: Thu, 23 Jul 1992 21:18:40 GMT
- Lines: 89
-
-
- ;;;; 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)
-