2.9 Macros that Expand into Calls to Advertised Functions

Some macros that take a "body" argument expand into a call to an advertised function that takes a functional argument. This functional argument will execute the suppled body. For a macro named "with-environment", the function is generally named "invoke-with-environment". For example, with-drawing-options might be defined as follows: [annotate]

(defgeneric invoke-with-drawing-options (medium continuation &key)
  (declare (dynamic-extent continuation)))

(defmacro with-drawing-options ((medium &rest drawing-options) &body body)
  `(flet ((with-drawing-options-body (,medium) ,@body))
     (declare (dynamic-extent #'with-drawing-options-body))
       ,medium #'with-drawing-options-body ,@drawing-options)))

(defmethod invoke-with-drawing-options 
           ((medium clx-display-medium) continuation &rest drawing-options)
  (with-drawing-options-merged-into-medium (medium drawing-options)
    (funcall continuation medium)))