0

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: 1. M-x Pfedj/write-async-file 2. uncomment ;;(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?

  • Do things work better if you add (fundamental-mode) just before the kill-whole-line? – rpluim Jul 25 '19 at 13:33
  • @rplium Nope. Same problem. – Pfedj Jul 25 '19 at 13:54
0

I could fix it by creating a new function in the file test.el that doesn't use kill ring.

test.el

(defun Pfedj/delete-line (&optional arg)
  (interactive "P")
  (flet ((kill-region (begin end)
                      (delete-region begin end)))
    (kill-line arg)))
(defun Pfedj/write-async-file ()
  (interactive)
  (async-start (lambda ()
                 (setq path "~/org/file.org")
                 (find-file path)
                 (load-file "~/.emacs.d/test.el")
                 (dotimes (i 400)
                   (beginning-of-buffer)
                   ;(kill-whole-line)
                   (Pfedj/delete-line)
                   (insert "foobar \n")
                   (save-buffer))
                 222)
               (lambda (result)
                 (message "Async process done, result should be 222: %s"
                          result))))

Now it works if smb can give explanation why it is so I welcome it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.