Repository: bokeh/bokeh

Issue:
remove spurious curplot
missed one: reference #1810 



Discussion:

Resolving patch:
diff --git a/bokeh/plotting.py b/bokeh/plotting.py
--- a/bokeh/plotting.py
+++ b/bokeh/plotting.py
@@ -239,7 +239,6 @@ def scatter(self, *args, **kwargs):
 
         markertype = kwargs.get("marker", "circle")
 
-        # TODO: How to handle this? Just call curplot()?
         if not len(_color_fields.intersection(set(kwargs.keys()))):
             kwargs['color'] = get_default_color()
         if not len(_alpha_fields.intersection(set(kwargs.keys()))):
@@ -467,25 +466,24 @@ def show(obj, browser=None, new="tab", url=None):
             controller.open(session.object_link(curdoc().context))
 
     elif filename:
-        save(filename, obj=obj)
+        save(obj, filename=filename)
         controller.open("file://" + os.path.abspath(filename), new=new_param)
 
 
-def save(filename=None, resources=None, obj=None, title=None):
+def save(obj, filename=None, resources=None, title=None):
     """ Updates the file with the data for the current document.
 
     If a filename is supplied, or output_file(...) has been called, this will
     save the plot to the given filename.
 
     Args:
-        filename (str, optional) : filename to save document under (default: None)
+        obj (Document or Widget/Plot object)
+        filename (str, optional) : filename to save document under
             if `filename` is None, the current output_file(...) filename is used if present
         resources (Resources, optional) : BokehJS resource config to use
             if `resources` is None, the current default resource config is used, failing that resources.INLINE is used
 
-        obj (Document or Widget/Plot object, optional)
-            if provided, then this is the object to save instead of curdoc()
-            and its curplot()
+
         title (str, optional) : title of the bokeh plot (default: None)
         	if 'title' is None, the current default title config is used, failing that 'Bokeh Plot' is used
 
@@ -516,12 +514,7 @@ def save(filename=None, resources=None, obj=None, title=None):
         warnings.warn("save() called but no title was supplied and output_file(...) was never called, using default title 'Bokeh Plot'")
         title = "Bokeh Plot"
 
-    if obj is None:
-        if not curplot():
-            warnings.warn("No current plot to save. Use renderer functions (circle, rect, etc.) to create a current plot (see http://bokeh.pydata.org/index.html)")
-            return
-        doc = curdoc()
-    elif isinstance(obj, Widget):
+    if isinstance(obj, Widget):
         doc = Document()
         doc.add(obj)
     elif isinstance(obj, Document):
@@ -595,11 +588,11 @@ def _deduplicate_plots(plot, subplots):
     doc.add(plot)
     doc._current_plot = plot # TODO (bev) don't use private attrs
 
-def _push_or_save():
+def _push_or_save(obj):
     if cursession() and curdoc().autostore:
         push()
     if _default_file and _default_file['autosave']:
-        save()
+        save(obj)
 
 def gridplot(plot_arrangement, **kwargs):
     """ Generate a plot that arranges several subplots into a grid.
@@ -616,7 +609,7 @@ def gridplot(plot_arrangement, **kwargs):
     grid = GridPlot(children=plot_arrangement, **kwargs)
     subplots = itertools.chain.from_iterable(plot_arrangement)
     _deduplicate_plots(grid, subplots)
-    _push_or_save()
+    _push_or_save(grid)
     return grid
 
 def load_object(obj):
diff --git a/examples/plotting/server/selection_histogram.py b/examples/plotting/server/selection_histogram.py
--- a/examples/plotting/server/selection_histogram.py
+++ b/examples/plotting/server/selection_histogram.py
@@ -13,14 +13,14 @@ def hbox(*children, **kwargs):
     """ Generate a plot that arranges several subplots horizontally. """
     layout = HBox(children=list(children), **kwargs)
     _deduplicate_plots(layout, children)
-    _push_or_save()
+    _push_or_save(layout)
     return layout
 
 def vbox(*children, **kwargs):
     """ Generate a plot that arranges several subplots vertically. """
     layout = VBox(children=list(children), **kwargs)
     _deduplicate_plots(layout, children)
-    _push_or_save()
+    _push_or_save(layout)
     return layout
 
 N = 5000


Test patch: