Function: skeleton-read

skeleton-read is an autoloaded and byte-compiled function defined in skeleton.el.gz.

Signature

(skeleton-read PROMPT &optional INITIAL-INPUT RECURSIVE)

Documentation

Function for reading a string from the minibuffer within skeletons.

PROMPT must be a string or a function that evaluates to a string. It may also be a form that evaluates to a string (deprecated). It may contain a %s which will be replaced by skeleton-subprompt. If non-nil second arg INITIAL-INPUT or variable input is a string or cons with index to insert before reading. If third arg RECURSIVE is non-nil i.e. we are handling the iterator of a subskeleton, returns empty string if user didn't modify input. While reading, the value of minibuffer-help-form is variable help if that is non-nil or a default string.

Source Code

;; Defined in /usr/src/emacs/lisp/skeleton.el.gz
(defun skeleton-read (prompt &optional initial-input recursive)
  "Function for reading a string from the minibuffer within skeletons.

PROMPT must be a string or a function that evaluates to a string.
It may also be a form that evaluates to a string (deprecated).
It may contain a `%s' which will be replaced by `skeleton-subprompt'.
If non-nil second arg INITIAL-INPUT or variable `input' is a string or
cons with index to insert before reading.  If third arg RECURSIVE is non-nil
i.e. we are handling the iterator of a subskeleton, returns empty string if
user didn't modify input.
While reading, the value of `minibuffer-help-form' is variable `help' if that
is non-nil or a default string."
  (with-suppressed-warnings ((lexical help)) (defvar help)) ;FIXME: Prefix!
  (let ((minibuffer-help-form (or (bound-and-true-p help)
				  (if recursive "\
As long as you provide input you will insert another subskeleton.

If you enter the empty string, the loop inserting subskeletons is
left, and the current one is removed as far as it has been entered.

If you quit, the current subskeleton is removed as far as it has been
entered.  No more of the skeleton will be inserted, except maybe for a
syntactically necessary termination."
				    "\
You are inserting a skeleton.  Standard text gets inserted into the buffer
automatically, and you are prompted to fill in the variable parts.")))
	(eolp (eolp)))
    ;; since Emacs doesn't show main window's cursor, do something noticeable
    (or eolp
        ;; We used open-line before, but that can do a lot more than we want,
	;; since it runs self-insert-command.  E.g. it may remove spaces
	;; before point.
        (save-excursion (insert "\n")))
    (unwind-protect
	(setq prompt (cond ((stringp prompt)
                            ;; The user may issue commands to move
                            ;; around (like `C-M-v').  Ensure that we
                            ;; insert the skeleton at the correct
                            ;; (initial) point.
                            (save-excursion
                              (read-string (format prompt skeleton-subprompt)
                                           (setq initial-input
                                                 (or initial-input
                                                     (symbol-value 'input))))))
                           ((functionp prompt)
                            (funcall prompt))
                           (t (eval prompt))))
      (or eolp
	  (delete-char 1))))
  (if (and recursive
	   (or (null prompt)
	       (string= prompt "")
	       (equal prompt initial-input)
	       (equal prompt (car-safe initial-input))))
      (signal 'quit t)
    prompt))