* gud.el: long completion lists
@ 2005-05-31 4:34 Nick Roberts
0 siblings, 0 replies; only message in thread
From: Nick Roberts @ 2005-05-31 4:34 UTC (permalink / raw)
The problem:
If there are a large number of GDB completions in GUD this can lock up Emacs
for an unreasonable amount of time e.g when debugging Emacs with M-x gdb try:
(gdb) b <TAB> (note the space between b and TAB)
If you then press C-g all the completions start to spill out into the
GUD buffer.
From the command line GDB uses readline and when there are a large number of
completions (over 100) it asks if the user wishes to proceed. For Emacs:
(gdb) b <TAB>
Display all 10513 possibilities? (y or n)
Completion with GDB in Emacs is a bit awkward and doesn't use readline but
the special GDB command "complete" with gud-gdb-complete-command.
The patch:
So that there are no ambiguities - this is not a "proper" patch but it does
show what I'm trying to do. It only works with "gdb --fullname", and not
perfectly.
Can anybody do any better?
Nick
*** /home/nick/emacs/lisp/progmodes/gud.el.~1.39.~ 2005-05-28 08:46:11.000000000 +1200
--- /home/nick/emacs/lisp/progmodes/gud.el 2005-05-31 16:14:06.000000000 +1200
***************
*** 606,611 ****
--- 606,613 ----
;; The completion list is constructed by the process filter.
(defvar gud-gdb-fetched-lines)
+ (defvar gud-gdb-items 0)
+
(defvar gud-comint-buffer nil)
(defun gud-gdb-complete-command ()
***************
*** 654,660 ****
;; The completion process filter is installed temporarily to slurp the
;; output of GDB up to the next prompt and build the completion list.
! (defun gud-gdb-fetch-lines-filter (string filter)
"Filter used to read the list of lines output by a command.
STRING is the output to filter.
It is passed through FILTER before we look at it."
--- 656,662 ----
;; The completion process filter is installed temporarily to slurp the
;; output of GDB up to the next prompt and build the completion list.
! (defun gud-gdb-fetch-lines-filter (string filter yes)
"Filter used to read the list of lines output by a command.
STRING is the output to filter.
It is passed through FILTER before we look at it."
***************
*** 663,668 ****
--- 665,675 ----
(while (string-match "\n" string)
(push (substring string gud-gdb-fetch-lines-break (match-beginning 0))
gud-gdb-fetched-lines)
+ (setq gud-gdb-items (+ 1 gud-gdb-items))
+ (unless (or yes (< gud-gdb-items 100))
+ (setq yes (y-or-n-p "Display all (over 100) possibilities? "))
+
+ (unless yes (throw 'gdb-no-display nil)))
(setq string (substring string (match-end 0))))
(if (string-match comint-prompt-regexp string)
(progn
***************
*** 744,761 ****
nil
;; Much of this copied from GDB complete, but I'm grabbing the stack
;; frame instead.
! (let ((gud-gdb-fetch-lines-in-progress t)
! (gud-gdb-fetched-lines nil)
! (gud-gdb-fetch-lines-string nil)
! (gud-gdb-fetch-lines-break (or skip 0))
! (gud-marker-filter
! `(lambda (string) (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
! ;; Issue the command to GDB.
! (gud-basic-call command)
! ;; Slurp the output.
! (while gud-gdb-fetch-lines-in-progress
! (accept-process-output (get-buffer-process buffer)))
! (nreverse gud-gdb-fetched-lines)))))
\f
;; ======================================================================
--- 751,772 ----
nil
;; Much of this copied from GDB complete, but I'm grabbing the stack
;; frame instead.
! (catch 'gdb-no-display
! (let ((gud-gdb-fetch-lines-in-progress t)
! (gud-gdb-fetched-lines nil)
! (gud-gdb-fetch-lines-string nil)
! (gud-gdb-fetch-lines-break (or skip 0))
! (gud-gdb-items 0)
! (yes nil)
! (gud-marker-filter
! `(lambda (string)
! (gud-gdb-fetch-lines-filter string ',gud-marker-filter yes))))
! ;; Issue the command to GDB.
! (gud-basic-call command)
! ;; Slurp the output.
! (while gud-gdb-fetch-lines-in-progress
! (accept-process-output (get-buffer-process buffer)))
! (nreverse gud-gdb-fetched-lines))))))
\f
;; ======================================================================
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-31 4:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-31 4:34 gud.el: long completion lists Nick Roberts
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).