Function: widget-editable-list-entry-create
widget-editable-list-entry-create is a byte-compiled function defined
in wid-edit.el.gz.
Signature
(widget-editable-list-entry-create WIDGET VALUE CONV)
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-editable-list-entry-create (widget value conv)
;; Create a new entry to the list.
(let ((type (nth 0 (widget-get widget :args)))
;; (widget-push-button-gui widget-editable-list-gui)
child delete insert)
(widget-specify-insert
(save-excursion
(and (widget--should-indent-p)
(widget-get widget :indent)
(insert-char ?\s (widget-get widget :indent)))
(insert (widget-get widget :entry-format)))
;; Parse % escapes in format.
(while (re-search-forward "%\\(.\\)" nil t)
(let ((escape (char-after (match-beginning 1))))
(delete-char -2)
(cond ((eq escape ?%)
(insert ?%))
((eq escape ?i)
(setq insert (apply #'widget-create-child-and-convert
widget 'insert-button
(widget-get widget :insert-button-args))))
((eq escape ?d)
(setq delete (apply #'widget-create-child-and-convert
widget 'delete-button
(widget-get widget :delete-button-args))))
((eq escape ?v)
(setq child (widget-create-child-value
widget type
(if conv value (widget-default-get type)))))
(t
(error "Unknown escape `%c'" escape)))))
(let ((buttons (widget-get widget :buttons)))
(if insert (push insert buttons))
(if delete (push delete buttons))
(widget-put widget :buttons buttons))
;; After creating the entry, we must check if we should indent the
;; following entry. This is necessary, for example, to keep the correct
;; indentation of editable lists inside group widgets.
(and (widget--should-indent-p t)
(widget-get widget :indent)
(insert-char ?\s (widget-get widget :indent)))
(let ((entry-from (point-min-marker))
(entry-to (point-max-marker)))
(set-marker-insertion-type entry-from t)
(set-marker-insertion-type entry-to nil)
(widget-put child :entry-from entry-from)
(widget-put child :entry-to entry-to)))
(if insert (widget-put insert :widget child))
(if delete (widget-put delete :widget child))
child))