* src/callproc.c (Fcall_process_region): Fix behavior when START is
nil and DELETE is non-nil.
* test/src/callproc-tests.el
(call-process-region-entire-buffer-with-delete): New unit test.
}
if (nargs > 3 && !NILP (args[3]))
- Fdelete_region (start, end);
+ {
+ if (NILP (start))
+ {
+ /* No need to save restrictions since we delete everything
+ anyway. */
+ Fwiden ();
+ del_range (BEG, Z);
+ }
+ else
+ Fdelete_region (start, end);
+ }
if (nargs > 3)
{
(error :got-error))))
(should have-called-debugger)))
+(ert-deftest call-process-region-entire-buffer-with-delete ()
+ "Check that Bug#40576 is fixed."
+ (let ((emacs (expand-file-name invocation-name invocation-directory)))
+ (skip-unless (file-executable-p emacs))
+ (with-temp-buffer
+ (insert "Buffer contents\n")
+ (should
+ (eq (call-process-region nil nil emacs :delete nil nil "--version") 0))
+ (should (eq (buffer-size) 0)))))
+
;;; callproc-tests.el ends here