home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / sources / 549 < prev    next >
Encoding:
Text File  |  1992-07-23  |  3.1 KB  |  102 lines

  1. Newsgroups: gnu.emacs.sources
  2. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevin
  3. From: kevin@traffic.den.mmc.com (Kevin Rodgers)
  4. Subject: gdb-completion.el
  5. Message-ID: <9207232118.AA24304@traffic>
  6. Sender: daemon@cis.ohio-state.edu
  7. Reply-To: kevin@traffic.den.mmc.com
  8. Organization: Source only  Discussion and requests in gnu.emacs.help.
  9. Distribution: gnu
  10. Date: Thu, 23 Jul 1992 21:18:40 GMT
  11. Lines: 89
  12.  
  13.  
  14. ;;;; gdb-completion.el
  15.  
  16. ;;;; Enable TAB, TAB-TAB, and ESC-? Gdb command completion.
  17.  
  18. ;;; Notes:
  19.  
  20. ;; 1. This depends upon comint-gdb.el by Mike Williams
  21. ;;    <mike-w@cs.aukuni.ac.nz>, which in turn depends upon comint.el by
  22. ;;    Olin Shivers <Olin.Shivers@cs.cmu.edu>.  Both of these are
  23. ;;    available via anonymous ftp from
  24. ;;    cs.cmu.edu:/afs/cs.cmu.edu/user/shivers/lib/emacs/.
  25.  
  26. ;; 2. To use gdb-completion, add these to your ~/.emacs file:
  27. ;;    (autoload (function gdb) "comint-gdb"
  28. ;;          "Major mode for interacting with an inferior Gdb process..." t)
  29. ;;    (setq gdb-load-hook
  30. ;;          (function (lambda ()
  31. ;;              (require 'gdb-completion))))
  32.  
  33. ;;; Bugs:
  34.  
  35. ;; 1. After a single TAB has been sent to the inferior Gdb process, the
  36. ;;    process may ring the bell by writing \a (i.e. C-g) on its standard
  37. ;;    error.  However, process filters only read from the standard
  38. ;;    output, so gdb-filter never detects the \a.
  39.  
  40. ;; 2. After two TABs or ESC ? have been sent to the inferior Gdb
  41. ;;    process, the process filter reads the completions, but doesn't see
  42. ;;    the echoed incomplete command line which should follow as a
  43. ;;    prompt.  I don't know why this is, since it doesn't seem to be
  44. ;;    written on the standard error.
  45.  
  46.  
  47. ;;; Gdb completion commands:
  48.  
  49. (defun gdb-complete ()
  50.   "*Complete Gdb command if unique, or display all possible completions
  51. when typed twice in a row."
  52.   (interactive)
  53.   (gdb-send-incomplete "\t"))
  54.  
  55. (defun gdb-display-completions ()
  56.   "*Display all possible Gdb command completions."
  57.   (interactive)
  58.   (gdb-send-incomplete "\e?"))
  59.  
  60. (defun gdb-send-incomplete (completion)
  61.   "Send input to inferior Gdb process, with COMPLETION string appended
  62. instead of newline."
  63.   (let ((comint-input-sender (function
  64.                   (lambda (proc string)
  65.                 ;; delete newline from buffer:
  66.                 (backward-delete-char 1)
  67.                 ;; send input to Gdb:
  68.                 (comint-send-string proc string)
  69.                 (comint-send-string proc completion)))))
  70.     (comint-send-input)))
  71.  
  72.  
  73. ;;; Bind the Gdb completion commands:
  74.  
  75. (define-key gdb-mode-map "\t" (function gdb-complete))
  76. (define-key gdb-mode-map "\M-?" (function gdb-display-completions))
  77.  
  78.  
  79. ;;; Modify the process output filter:
  80.  
  81. (fset 'original-gdb-filter (symbol-function 'gdb-filter))
  82.  
  83. (defun gdb-filter (proc string)
  84.   (let ((match-data (match-data))
  85.     (prev-point-max (point-max)))
  86.     (funcall (function original-gdb-filter) proc string)
  87.     (unwind-protect
  88.     (save-excursion
  89.       (goto-char prev-point-max)
  90.       (forward-line -1)
  91.       (while (or (search-forward "\^M" (point-max) t)
  92.              (let ((alarm (search-forward "\a" (point-max) t)))
  93.                (if alarm (beep t))
  94.                alarm))
  95.         (replace-match "")))
  96.       (store-match-data match-data))))
  97.  
  98.  
  99. ;;; Advertise the provided feature:
  100.  
  101. (provide 'gdb-completion)
  102.