Function: gud-gdb-completions-1
gud-gdb-completions-1 is a byte-compiled function defined in
gud.el.gz.
Signature
(gud-gdb-completions-1 COMPLETE-LIST)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; This function is also used by `gud-gdbmi-completions'.
(defun gud-gdb-completions-1 (complete-list)
;; Sort the list like readline.
(setq complete-list (sort complete-list (function string-lessp)))
;; Remove duplicates.
(let ((first complete-list)
(second (cdr complete-list)))
(while second
(if (string-equal (car first) (car second))
(setcdr first (setq second (cdr second)))
(setq first second
second (cdr second)))))
;; Add a trailing single quote if there is a unique completion
;; and it contains an odd number of unquoted single quotes.
(and (= (length complete-list) 1)
(let ((str (car complete-list))
(pos 0)
(count 0))
(while (string-match "\\([^'\\]\\|\\\\'\\)*'" str pos)
(setq count (1+ count)
pos (match-end 0)))
(and (= (mod count 2) 1)
(setq complete-list (list (concat str "'"))))))
complete-list)