Function: minibuf-eldef-setup-minibuffer
minibuf-eldef-setup-minibuffer is a byte-compiled function defined in
minibuf-eldef.el.gz.
Signature
(minibuf-eldef-setup-minibuffer)
Documentation
Set up a minibuffer for minibuffer-electric-default-mode(var)/minibuffer-electric-default-mode(fun).
The prompt and initial input should already have been inserted.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuf-eldef.el.gz
;;; Hook functions
;; This function goes on minibuffer-setup-hook
(defun minibuf-eldef-setup-minibuffer ()
"Set up a minibuffer for `minibuffer-electric-default-mode'.
The prompt and initial input should already have been inserted."
(let ((regexps minibuffer-default-in-prompt-regexps)
(match nil))
(save-excursion
(save-restriction
;; Narrow to only the prompt.
(goto-char (point-min))
(narrow-to-region (point) (minibuffer-prompt-end))
;; See if the prompt contains a default input indicator.
(while regexps
(setq match (pop regexps))
(cond
((not (re-search-forward (if (stringp match) match (car match))
nil t))
;; No match yet, try the next rule.
(setq match nil))
((and (consp (cdr-safe match)) (nth 2 match))
;; Matched a replacement rule.
(let* ((inhibit-read-only t)
(buffer-undo-list t)
(submatch (nth 1 match))
(replacement (nth 2 match))
(props (text-properties-at (match-beginning submatch))))
(replace-match replacement nil nil nil submatch)
(set-text-properties (match-beginning submatch)
(match-end submatch)
props)
;; Replacement done, now keep trying with subsequent rules.
(setq match nil)
(goto-char (point-min))))
;; Matched a non-replacement (i.e. electric hide) rule, no need to
;; keep trying.
(t (setq regexps nil))))))
(if (not match)
;; No match for electric hiding, so just make sure our
;; post-command-hook isn't left around.
(remove-hook 'post-command-hook #'minibuf-eldef-update-minibuffer t)
;; Yup; set things up so we can frob the prompt as the state of
;; the input string changes.
(setq match (if (consp match) (cdr match) 0))
(setq match (if (consp match) (car match) match))
(setq minibuf-eldef-overlay
(make-overlay (match-beginning match) (match-end match)))
(setq minibuf-eldef-showing-default-in-prompt t)
(setq minibuf-eldef-initial-input
(minibuffer-contents-no-properties))
(setq minibuf-eldef-initial-buffer-length (point-max))
(add-to-list 'minibuf-eldef-frobbed-minibufs (current-buffer))
(add-hook 'post-command-hook #'minibuf-eldef-update-minibuffer nil t))))