Function: mh-complete-word

mh-complete-word is an autoloaded and byte-compiled function defined in mh-letter.el.gz.

Signature

(mh-complete-word WORD CHOICES BEGIN END)

Documentation

Complete WORD from CHOICES.

Any match found replaces the text from BEGIN to END.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-letter.el.gz
;;;###mh-autoload
(defun mh-complete-word (word choices begin end)
  "Complete WORD from CHOICES.
Any match found replaces the text from BEGIN to END."
  (let ((completion (try-completion word choices))
        (completions-buffer "*Completions*"))
    (cond ((eq completion t)
           (ignore-errors
             (kill-buffer completions-buffer))
           (message "Completed: %s" word))
          ((null completion)
           (ignore-errors
             (kill-buffer completions-buffer))
           (message "No completion for %s" word))
          ((stringp completion)
           (if (equal word completion)
               (with-output-to-temp-buffer completions-buffer
                 (display-completion-list
                  (completion-hilit-commonality
                   (all-completions word choices)
                   ;; The `common-substring' arg only works if it's a prefix.
                   (unless (and (functionp choices)
                                (let ((bounds
                                       (funcall choices
                                                word nil '(boundaries . ""))))
                                  (and (eq 'boundaries (car-safe bounds))
                                       (< 0 (cadr bounds)))))
                     word))))
             (ignore-errors
               (kill-buffer completions-buffer))
             (delete-region begin end)
             (insert completion))))))