- (setq dabbrev--last-completion-buffer (current-buffer))
- ;; Find the longest common string.
- (setq init (try-completion abbrev my-obarray))))
- ;;--------------------------------
- ;; Let the user choose between the expansions
- ;;--------------------------------
- (or (stringp init)
- (setq init abbrev))
- (cond
- ;; * Replace string fragment with matched common substring completion.
- ((and (not (string-equal init ""))
- (not (string-equal (downcase init) (downcase abbrev))))
- (if (> (length (all-completions init my-obarray)) 1)
- (message "Repeat `%s' to see all completions"
- (key-description (this-command-keys)))
- (message "The only possible completion"))
- (dabbrev--substitute-expansion nil abbrev init nil))
- (t
- ;; * String is a common substring completion already. Make list.
- (message "Making completion list...")
- (with-output-to-temp-buffer "*Completions*"
- (display-completion-list (all-completions init my-obarray)
- init))
- (message "Making completion list...done")))
- (and (window-minibuffer-p (selected-window))
- (message nil))))