0

How do you wrote an abortable function, so that when user presses C-g during execution, this function is "stopped"

;; my function so far
(defun my/elfeed-extra-info-2 ()
  (interactive)
  (next-line)
  (message "here1")
  (sleep-for 0.5)
  (next-line)
  (message "here2")
  (sleep-for 0.5)
  (next-line)
  (message "here3")
  (sleep-for 0.5)
  (next-line)
  (message "here4")
  (sleep-for 0.5)
  (next-line)
  (message "here5")
  (sleep-for 0.5)
  (next-line)
  (message "here6")
  (sleep-for 0.5)
  (next-line)
  (message "here7")
  (sleep-for 0.5)
  (next-line)
  (message "here8")
  (sleep-for 0.5)
)
Drew
  • 77,472
  • 10
  • 114
  • 243
american-ninja-warrior
  • 3,903
  • 2
  • 24
  • 44
  • This is pretty much a duplicate of your other question, don't use sleep-for. – wasamasa Jul 06 '18 at 17:15
  • This works just fine for me: C-g aborts the function. – Tyler Jul 06 '18 at 17:41
  • In my experience it depends on the operating system whether quit works reliable. Under Linux it works perfect (also for my/elfeed-extra-info-2) while under cygwin I often have emacs hanging without being able to quit via C-g. I have to use pkill -SIGUSR2 emacs from the command line in those cases. If you experience problems with your function please extend your question with system information and with a detailed description what happens on your system if you press C-g. – Tobias Jul 06 '18 at 21:18

0 Answers0