Function: comint-dynamic-simple-complete

comint-dynamic-simple-complete is a byte-compiled function defined in comint.el.gz.

This function is obsolete since 24.1; use completion-in-region instead.

Signature

(comint-dynamic-simple-complete STUB CANDIDATES)

Documentation

Dynamically complete STUB from CANDIDATES list.

This function inserts completion characters at point by completing STUB from the strings in CANDIDATES. If completion is ambiguous, possibly show a completions listing in a separate buffer.

Return nil if no completion was inserted. Return sole if completed with the only completion match. Return shortest if completed with the shortest match. Return partial if completed as far as possible. Return listed if a completion listing was shown.

See also comint-dynamic-complete-filename.

Probably introduced at or before Emacs version 19.20.

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-dynamic-simple-complete (stub candidates)
  "Dynamically complete STUB from CANDIDATES list.
This function inserts completion characters at point by
completing STUB from the strings in CANDIDATES.  If completion is
ambiguous, possibly show a completions listing in a separate
buffer.

Return nil if no completion was inserted.
Return `sole' if completed with the only completion match.
Return `shortest' if completed with the shortest match.
Return `partial' if completed as far as possible.
Return `listed' if a completion listing was shown.

See also `comint-dynamic-complete-filename'."
  (declare (obsolete completion-in-region "24.1"))
  (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin)))
	 (minibuffer-p (window-minibuffer-p))
	 (suffix (cond ((not comint-completion-addsuffix) "")
		       ((not (consp comint-completion-addsuffix)) " ")
		       (t (cdr comint-completion-addsuffix))))
	 (completions (all-completions stub candidates)))
    (cond ((null completions)
	   (if minibuffer-p
	       (minibuffer-message "No completions of %s" stub)
	     (message "No completions of %s" stub))
	   nil)
	  ((= 1 (length completions))	; Gotcha!
	   (let ((completion (car completions)))
	     (if (string-equal completion stub)
		 (unless minibuffer-p
		   (message "Sole completion"))
	       (insert (substring completion (length stub)))
	       (unless minibuffer-p
		 (message "Completed")))
	     (insert suffix)
	     'sole))
	  (t				; There's no unique completion.
	   (let ((completion (try-completion stub candidates)))
	     ;; Insert the longest substring.
	     (insert (substring completion (length stub)))
	     (cond ((and comint-completion-recexact comint-completion-addsuffix
			 (string-equal stub completion)
			 (member completion completions))
		    ;; It's not unique, but user wants shortest match.
		    (insert suffix)
		    (unless minibuffer-p
		      (message "Completed shortest"))
		    'shortest)
		   ((or comint-completion-autolist
			(string-equal stub completion))
		    ;; It's not unique, list possible completions.
		    (comint-dynamic-list-completions completions stub)
		    'listed)
		   (t
		    (unless minibuffer-p
		      (message "Partially completed"))
		    'partial)))))))