home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.sources
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!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: <9207242119.AA26868@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: Fri, 24 Jul 1992 21:19:54 GMT
- Lines: 112
-
-
- After posting gdb-completion.el yesterday, I've made some fixes to
- gdb-filter:
-
- 1. (set-buffer (process-buffer PROC)) before modifying the current
- buffer :-), and restore the current buffer on exit.
-
- 2. Correctly delete all unprintable characters (not just ^M and \a),
- emulate \f as well as \a, and restore point to the end of the buffer.
-
- 3. Make use of the process marker.
-
- 4. Add comments and a documentation string.
-
- So here's the new and improved version:
-
- ;;;; 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 'comint-gdb-filter (symbol-function 'gdb-filter))
-
- (defun gdb-filter (proc string)
- "Call comint-gdb-filter with PROC and STRING, then delete the unprintable
- characters that were inserted into the process buffer."
- (let ((buffer (current-buffer))
- (match-data (match-data)))
- (unwind-protect ; restore buffer and match data
- (let ((position (marker-position (process-mark proc))))
- (funcall (function comint-gdb-filter) proc string)
- (set-buffer (process-buffer proc))
- (goto-char position)
- (while (and (re-search-forward "[^\t\n -~]" (point-max) t)
- (let ((unprintable-char (char-after (match-beginning 0))))
- ;; primitive terminal emulation:
- (cond ((char-equal unprintable-char ?\a) (beep t))
- ((char-equal unprintable-char ?\f) (recenter 0)))
- ;; always true:
- t))
- (replace-match ""))
- ;; restore point:
- (goto-char (point-max)))
- (set-buffer buffer)
- (store-match-data match-data))))
-
-
- ;;; Advertise the provided feature:
-
- (provide 'gdb-completion)
-