Function: toolbarx-merge-props

toolbarx-merge-props is a byte-compiled function defined in toolbar-x.el.

Signature

(toolbarx-merge-props INNER-PROPS OUTER-PROPS OVERRIDE ADD)

Documentation

Merge property lists INNER-PROPS and OUTER-PROPS.

INNER-PROPS and OUTER-PROPS are two lists in the format
 (PROP VAL PROP VAL ... PROP VAL).
Returns a list with properties and values merged.

OVERRIDE and ADD are supposed to be lists of symbols. The value of a property in OVERRIDE is the one on OUTER-PROPS or INNER-PROPS, but if the property is in both, the value in INNER-PROPS is used. The value of a property in ADD will be a list with first element the symbol :add-value-list and the rest are the properties, inner properties first.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/toolbar-x.el
(defun toolbarx-merge-props (inner-props outer-props override add)
  "Merge property lists INNER-PROPS and OUTER-PROPS.
INNER-PROPS and OUTER-PROPS are two lists in the format
 (PROP VAL PROP VAL ... PROP VAL).
Returns a list with properties and values merged.

OVERRIDE and ADD are supposed to be lists of symbols.  The value
of a property in OVERRIDE is the one on OUTER-PROPS or
INNER-PROPS, but if the property is in both, the value in
INNER-PROPS is used.  The value of a property in ADD will be a
list with first element the symbol `:add-value-list' and the rest
are the properties, inner properties first."
  (let* ((merged)
         (inner-prop)
         (outer-prop))
    (dolist (prop override)
      (if (memq prop inner-props)
          (setq merged (append merged
                               (list prop (cadr (memq prop inner-props)))))
        (when (memq prop outer-props)
          (setq merged (append merged
                               (list prop (cadr (memq prop outer-props))))))))
    (dolist (prop add merged)
      (setq inner-prop (memq prop inner-props))
      (when inner-prop
        (if (and (listp (cadr inner-prop))
                 (eq (car (cadr inner-prop)) :add-value-list))
            (setq inner-prop (cdr (cadr inner-prop)))
          (setq inner-prop (list (cadr inner-prop)))))
      (setq outer-prop (memq prop outer-props))
      (when outer-prop
        (if (and (listp (cadr outer-prop))
                 (eq (car (cadr outer-prop)) :add-value-list))
            (setq outer-prop (cdr (cadr outer-prop)))
          (setq outer-prop (list (cadr outer-prop)))))
      (when (append inner-prop outer-prop)
        (setq merged (append merged
                             (list prop (cons :add-value-list
                                              (append inner-prop
                                                      outer-prop)))))))))