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

  1. 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
  2. From: kevin@traffic.den.mmc.com (Kevin Rodgers)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: Help with gdb-4.6 and gdb-mode (Command-completion with TAB)
  5. Message-ID: <1992Jul23.211418.939@den.mmc.com>
  6. Date: 23 Jul 92 21:14:18 GMT
  7. References: <ROLF.92Jul17164511@green.mathematik.uni-stuttgart.de>
  8. Sender: news@den.mmc.com (News)
  9. Organization: Martin Marietta Western Internal Systems, Technical Operations
  10. Lines: 106
  11. Nntp-Posting-Host: traffic.den.mmc.com
  12.  
  13. In article <ROLF.92Jul17164511@green.mathematik.uni-stuttgart.de> rolf@green.mathematik.uni-stuttgart.de (Rolf Schreiber) writes:
  14. >With gdb-4.6 you can use command-completion on c++ function names.
  15. >This seems to be very useful, but is done with TAB, TAB-TAB and ESC-?,
  16. >which all don't pass through emacs-gdb-mode.
  17. >
  18. >So could anybody help me, what to change in gdb-mode.el or my .emacs
  19. >file, so I can use this feature of gdb?
  20.  
  21. I investigated gdb.el and shell.el, and this is the best I could come up
  22. with.  See the note on comint-gdb.el and comint.el, and don't forget to
  23. delete my .sig from the end of this article.  [This will also appear
  24. soon in gnu.emacs.sources.]
  25.  
  26. ;;;; gdb-completion.el
  27.  
  28. ;;;; Enable TAB, TAB-TAB, and ESC-? Gdb command completion.
  29.  
  30. ;;; Notes:
  31.  
  32. ;; 1. This depends upon comint-gdb.el by Mike Williams
  33. ;;    <mike-w@cs.aukuni.ac.nz>, which in turn depends upon comint.el by
  34. ;;    Olin Shivers <Olin.Shivers@cs.cmu.edu>.  Both of these are
  35. ;;    available via anonymous ftp from
  36. ;;    cs.cmu.edu:/afs/cs.cmu.edu/user/shivers/lib/emacs/.
  37.  
  38. ;; 2. To use gdb-completion, add these to your ~/.emacs file:
  39. ;;    (autoload (function gdb) "comint-gdb"
  40. ;;          "Major mode for interacting with an inferior Gdb process..." t)
  41. ;;    (setq gdb-load-hook
  42. ;;          (function (lambda ()
  43. ;;              (require 'gdb-completion))))
  44.  
  45. ;;; Bugs:
  46.  
  47. ;; 1. After a single TAB has been sent to the inferior Gdb process, the
  48. ;;    process may ring the bell by writing \a (i.e. C-g) on its standard
  49. ;;    error.  However, process filters only read from the standard
  50. ;;    output, so gdb-filter never detects the \a.
  51.  
  52. ;; 2. After two TABs or ESC ? have been sent to the inferior Gdb
  53. ;;    process, the process filter reads the completions, but doesn't see
  54. ;;    the echoed incomplete command line which should follow as a
  55. ;;    prompt.  I don't know why this is, since it doesn't seem to be
  56. ;;    written on the standard error.
  57.  
  58.  
  59. ;;; Gdb completion commands:
  60.  
  61. (defun gdb-complete ()
  62.   "*Complete Gdb command if unique, or display all possible completions
  63. when typed twice in a row."
  64.   (interactive)
  65.   (gdb-send-incomplete "\t"))
  66.  
  67. (defun gdb-display-completions ()
  68.   "*Display all possible Gdb command completions."
  69.   (interactive)
  70.   (gdb-send-incomplete "\e?"))
  71.  
  72. (defun gdb-send-incomplete (completion)
  73.   "Send input to inferior Gdb process, with COMPLETION string appended
  74. instead of newline."
  75.   (let ((comint-input-sender (function
  76.                   (lambda (proc string)
  77.                 ;; delete newline from buffer:
  78.                 (backward-delete-char 1)
  79.                 ;; send input to Gdb:
  80.                 (comint-send-string proc string)
  81.                 (comint-send-string proc completion)))))
  82.     (comint-send-input)))
  83.  
  84.  
  85. ;;; Bind the Gdb completion commands:
  86.  
  87. (define-key gdb-mode-map "\t" (function gdb-complete))
  88. (define-key gdb-mode-map "\M-?" (function gdb-display-completions))
  89.  
  90.  
  91. ;;; Modify the process output filter:
  92.  
  93. (fset 'original-gdb-filter (symbol-function 'gdb-filter))
  94.  
  95. (defun gdb-filter (proc string)
  96.   (let ((match-data (match-data))
  97.     (prev-point-max (point-max)))
  98.     (funcall (function original-gdb-filter) proc string)
  99.     (unwind-protect
  100.     (save-excursion
  101.       (goto-char prev-point-max)
  102.       (forward-line -1)
  103.       (while (or (search-forward "\^M" (point-max) t)
  104.              (let ((alarm (search-forward "\a" (point-max) t)))
  105.                (if alarm (beep t))
  106.                alarm))
  107.         (replace-match "")))
  108.       (store-match-data match-data))))
  109.  
  110.  
  111. ;;; Advertise the provided feature:
  112.  
  113. (provide 'gdb-completion)
  114. -- 
  115. Kevin Rodgers                kevin@traffic.den.mmc.com
  116. Martin Marietta MS A16401        (303) 790-3971
  117. 116 Inverness Dr. East
  118. Englewood CO 80112 USA            GO BUFFS!
  119.