Emacs 27.0.50. Windows 10.
This function works finely when the line is commented:
(defun Pfedj/write-async-file () (interactive) (async-start (lambda () (setq path "~/org/file.org") (find-file path) (dotimes (i 500) (beginning-of-buffer) ;;(kill-whole-line) ;; <= with this line Emacs freezes for 20-30 sec (insert "foobar \n") (save-buffer)) 222) (lambda (result) (message "Async process done, result should be 222: %s" result))))
If the following steps will be executed:
;;(kill-whole-line) and repeat
M-x Pfedj/write-async-file Emacs freezes for 20-30 sec.
Why does it happen? How can I profix it?