From: Nick Roberts <nickrob@snap.net.nz>
Subject: gud.el: long completion lists
Date: Tue, 31 May 2005 16:34:42 +1200 [thread overview]
Message-ID: <17051.59746.416086.643078@farnswood.snap.net.nz> (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
;; ======================================================================
reply other threads:[~2005-05-31 4:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17051.59746.416086.643078@farnswood.snap.net.nz \
--to=nickrob@snap.net.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).