Function: org-replace-buffer-contents

org-replace-buffer-contents is a function alias and interactive for replace-buffer-contents, defined in editfns.c.

Signature

(org-replace-buffer-contents SOURCE &optional MAX-SECS MAX-COSTS)

Documentation

Replace accessible portion of current buffer with that of SOURCE.

SOURCE can be a buffer or a string that names a buffer. Interactively, prompt for SOURCE.

As far as possible the replacement is non-destructive, i.e. existing buffer contents, markers, properties, and overlays in the current buffer stay intact.

Because this function can be very slow if there is a large number of differences between the two buffers, there are two optional arguments mitigating this issue.

The MAX-SECS argument, if given, defines a hard limit on the time used for comparing the buffers. If it takes longer than MAX-SECS, the function falls back to a plain delete-region and insert-buffer-substring. (Note that the checks are not performed too evenly over time, so in some cases it may run a bit longer than allowed).

The optional argument MAX-COSTS defines the quality of the difference computation. If the actual costs exceed this limit, heuristics are used to provide a faster but suboptimal solution. The default value is 1000000.

This function returns t if a non-destructive replacement could be performed. Otherwise, i.e., if MAX-SECS was exceeded, it returns nil.

Key Bindings

Aliases

org-replace-buffer-contents