summaryrefslogtreecommitdiff
path: root/dot_config/emacs/lisp/doom-quit.el
blob: 009aff0c3802dda960c762be696575b76f4bdafd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(defvar +doom-quit-messages
  `(;; from Doom 1
    "Please don't leave, there's more demons to toast!"
    "Let's beat it -- This is turning into a bloodbath!"
    ,(format "I wouldn't leave if I were you. %s is much worse."
             (if (featurep :system 'windows) "DOS" "UNIX"))
    "Don't leave yet -- There's a demon around that corner!"
    "Ya know, next time you come in here I'm gonna toast ya."
    "Go ahead and leave. See if I care."
    "Are you sure you want to quit this great editor?"
    ;; from Doom 2
    ,(format "Don't go now, there's a dimensional shambler waiting at the %s prompt!"
             (if (featurep :system 'windows) "DOS" "UNIX"))
    "Get outta here and go back to your boring operating system."
    "Look, bud. You leave now and you forfeit your body count!"
    "Just leave. When you come back, I'll be waiting with a bat."
    "You're lucky I don't smack you for thinking about leaving."
    ;; from Portal
    "Thank you for participating in this Aperture Science computer-aided enrichment activity."
    "You can't fire me, I quit!"
    "I don't know what you think you are doing, but I don't like it. I want you to stop."
    "This isn't brave. It's murder. What did I ever do to you?"
    "I'm the man who's going to burn your house down! With the lemons!"
    "Okay, look. We've both said a lot of things you're going to regret..."
    ;; Custom
    "(setq nothing t everything 'permitted)"
    "Emacs will remember that."
    "Emacs, Emacs never changes."
    "Hey! Hey, M-x listen!"
    "It's not like I'll miss you or anything, b-baka!"
    "Wake up, Mr. Stallman. Wake up and smell the ashes."
    "You are *not* prepared!"
    "Please don't go. The drones need you. They look up to you."
    "Don't forget, you're here forever.")
  "A list of quit messages, picked randomly by `+doom-quit'. Taken from
http://doom.wikia.com/wiki/Quit_messages and elsewhere.")

(defun +doom-quit-fn (&rest _)
  (doom-quit-p
   (format "%s  %s"
           (propertize (nth (random (length +doom-quit-messages))
                            +doom-quit-messages)
                       'face '(italic default))
           "Really quit Emacs?")))


(defun doom-quit-p (&optional prompt)
  (if use-dialog-box
      (x-popup-dialog
       t `("Really quit Emacs?"
           ("Yes" . t)
           ("Cancel" . nil)))
    (let ((confirmed (y-or-n-p (format "%s" (or prompt "Really quit Emacs?")))))
      (if confirmed
          t
        (progn
          (message "Aborted")
          nil)))))

(setq confirm-kill-emacs #'+doom-quit-fn)

(provide 'doom-quit)