Skip to content

Instantly share code, notes, and snippets.

@svanellewee
Last active November 30, 2023 13:05
Show Gist options
  • Save svanellewee/30590d8acdfed808af916d05008bb505 to your computer and use it in GitHub Desktop.
Save svanellewee/30590d8acdfed808af916d05008bb505 to your computer and use it in GitHub Desktop.
Emacs Lisp Gist: DEFER-ing/ Python's try finally
(defun some-dodgey-function (value)
(let* ((result (/ 10 value)))
(message "Rwesult is %d" result)))
(defun some-recovery-or-cleanup-code-to-always-run ()
(message "I ALWAwYS RUN!!!"))
(unwind-protect
(some-dodgey-function 0)
(some-recovery-or-cleanup-code-to-always-run))
let*: Arithmetic error
next-line: End of buffer [2 times]
I ALWAwYS RUN!!!
@svanellewee
Copy link
Author

I suppose it's more like python's try: finally. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment