Subject: 27.2.50; gud-gdb should use "server complete"

From: Tom Tromey <[email-masked]>
Date: Fri, 31 Dec 2021 14:41:16 -0700

gud-gdb sends a "complete" command to gdb to implement command line
completion.  It would be better to send "server complete".  This is what
Emacs does for other behind-the-scenes commands it sends.

First, this would prevent the "complete" command from showing up in
gdb's history (not normally visible in Emacs but some people arrange to
have it auto-saved by gdb).  

Second, I'd like to change how "complete" is implemented in gdb, for
some internal reasons.  With this future code, the "server" command will
also help prevent unwanted pagination by gdb's output stream.

Here's a patch.  Normally I'd install it, but I haven't been very active
in Emacs lately.

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index d5bd265517..113da24749 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -869,7 +869,8 @@ gud-gdb-completions
 COMMAND is the prefix for which we seek completion.
 CONTEXT is the text before COMMAND on the line."
   (let* ((complete-list
-	  (gud-gdb-run-command-fetch-lines (concat "complete " context command)
+	  (gud-gdb-run-command-fetch-lines (concat "server complete "
+                                                   context command)
 					   (current-buffer)
 					   ;; From string-match above.
 					   (length context))))

In GNU Emacs 27.2.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2021-04-08 built on localhost.localdomain
Repository revision: 2f5f30671a122aeed0a78dbee8f541dda5a6d4c2
Repository branch: emacs-27
Windowing system distributor 'The X.Org Foundation', version 11.0.12101002
System Description: Fedora 34 (Workstation Edition)

Recent messages:
Saving file /home/tromey/gdb/binutils-gdb/.git/rebase-merge/git-rebase-todo...
Wrote /home/tromey/gdb/binutils-gdb/.git/rebase-merge/git-rebase-todo
When done with a buffer, type C-x #
Auto-saving...done
Save file /home/tromey/gdb/binutils-gdb/.git/COMMIT_EDITMSG? (y, n, !, ., q, C-r, C-f, d or C-h) 
Save file /home/tromey/gdb/binutils-gdb/.git/COMMIT_EDITMSG? (y, n, !, ., q, C-r, C-f, d or C-h) y
Saving file /home/tromey/gdb/binutils-gdb/.git/COMMIT_EDITMSG...
Delete excess backup versions of /home/tromey/gdb/binutils-gdb/.git/COMMIT_EDITMSG? (y or n) y
Wrote /home/tromey/gdb/binutils-gdb/.git/COMMIT_EDITMSG
C-x C-g is undefined

Configured using:
 'configure --prefix=/home/tromey/Emacs/install'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS JSON PDUMPER GMP

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Git-Log-View

Minor modes in effect:
  shell-dirtrack-mode: t
  which-function-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/27.2.50/lisp/play/bubbles

Features:
(shadow sort mail-hist mail-extr emacsbug sendmail copyright ggtags
hippie-exp etags fileloop xref project bug-reference misearch
multi-isearch term/xterm xterm texinfo smerge-mode diff cc-mode cc-fonts
cc-guess cc-menus cc-cmds log-view pcvs-util add-log vc-mtn vc-hg
org-bullets org-element avl-tree generator ol-eww eww mm-url url-queue
ol-rmail ol-mhe ol-irc ol-info ol-gnus nnir gnus-sum url url-proxy
url-privacy url-expand url-methods url-history mailcap shr url-cookie
url-domsuf url-util svg xml dom gnus-group gnus-undo gnus-start
gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int
gnus-range message rmc puny rfc822 mml mml-sec epa derived epg
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search
mail-utils mm-util mail-prsvr ol-docview doc-view jka-compr image-mode
exif dired dired-loaddefs ol-bibtex bibtex ol-bbdb ol-w3m org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src
ob-comint org-pcomplete org-list org-faces org-entities noutline outline
org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys
org-compat org-macs org-loaddefs find-func cl-extra help-mode vc-git
diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs flyspell ispell
diminish projectile ibuf-macs pcase edmacro kmacro grep compile ibuf-ext
ibuffer ibuffer-loaddefs dash appt diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs tramp tramp-loaddefs trampver tramp-integration
files-x tramp-compat shell pcomplete parse-time iso8601 time-date
ls-lisp which-func imenu minimap autorevert filenotify cus-start
cus-load erc-track erc-match erc-services erc-networks erc-hl-nicks
easy-mmode color erc-button erc-fill erc-stamp wid-edit erc-goodies erc
erc-backend erc-compat format-spec thingatpt pp erc-loaddefs warnings
advice vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars
cc-defs ange-ftp comint ansi-color ring server savehist finder-inf
gdb-shell-autoloads lisppaste-autoloads pydoc-info-autoloads info-look
info cl weblogger-autoloads package easymenu browse-url url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 450482 34933)
 (symbols 48 35785 2)
 (strings 32 131183 6643)
 (string-bytes 1 4402636)
 (vectors 16 54088)
 (vector-slots 8 1008411 142466)
 (floats 8 416 530)
 (intervals 56 9666 25)
 (buffers 1000 36))