Function: widget--prepare-markers-for-inside-insertion

widget--prepare-markers-for-inside-insertion is a byte-compiled function defined in wid-edit.el.gz.

Signature

(widget--prepare-markers-for-inside-insertion WIDGET)

Documentation

Prepare the WIDGET's parent for insertions inside it, if necessary.

Usually, the :from marker has type t, while the :to marker has type nil. When recreating a child or a button inside a composite widget right at these markers, they have to be changed to nil and t respectively, so that the WIDGET's parent (if any), properly contains all of its recreated children and buttons.

Prepares also the markers of the WIDGET's grandparent, if necessary.

Returns a list of the markers that had its type changed, for later resetting.

Source Code

;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget--prepare-markers-for-inside-insertion (widget)
  "Prepare the WIDGET's parent for insertions inside it, if necessary.

Usually, the :from marker has type t, while the :to marker has type nil.
When recreating a child or a button inside a composite widget right at these
markers, they have to be changed to nil and t respectively,
so that the WIDGET's parent (if any), properly contains all of its
recreated children and buttons.

Prepares also the markers of the WIDGET's grandparent, if necessary.

Returns a list of the markers that had its type changed, for later resetting."
  (let* ((parent (widget-get widget :parent))
         (parent-from-marker (and parent (widget-get parent :from)))
         (parent-to-marker (and parent (widget-get parent :to)))
         (lst nil)
         (pos (point)))
    (when (and parent-from-marker
               (eq pos (marker-position parent-from-marker))
               (marker-insertion-type parent-from-marker))
      (set-marker-insertion-type parent-from-marker nil)
      (push (cons parent-from-marker t) lst))
    (when (and parent-to-marker
               (eq pos (marker-position parent-to-marker))
               (not (marker-insertion-type parent-to-marker)))
      (set-marker-insertion-type parent-to-marker t)
      (push (cons parent-to-marker nil) lst))
    (when lst
      (nconc lst (widget--prepare-markers-for-inside-insertion parent)))))