aboutsummaryrefslogtreecommitdiff
path: root/editors/sly/files/patch-sly.el
blob: 4f9c8a3cf619235e7ce5d074d77abeeefa47a032 (plain) (blame)
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
--- sly.el.orig	2021-01-14 09:12:56 UTC
+++ sly.el
@@ -7463,22 +7463,30 @@ can be found."
 ;;;###autoload
 (add-hook 'lisp-mode-hook 'sly-editing-mode)
 
-(cond
- ((or (not (memq 'slime-lisp-mode-hook lisp-mode-hook))
-      noninteractive
-      (prog1
-          (y-or-n-p "[sly] SLIME detected in `lisp-mode-hook', causes keybinding conflicts.  Remove it for this Emacs session?")
-        (warn "To restore SLIME in this session, customize `lisp-mode-hook'
-and replace `sly-editing-mode' with `slime-lisp-mode-hook'.")))
-  (remove-hook 'lisp-mode-hook 'slime-lisp-mode-hook)
+(let ((proceed-p
+       (if noninteractive
+           (lambda () t)
+         (let (asked resp)
+           (lambda ()
+             (unless asked
+               (setq resp
+                     (y-or-n-p
+                      (eval-when-compile
+                        (concat "[sly] SLIME detected. Try to disable it "
+                                "for this Emacs session?")))
+                     asked t))
+             resp)))))
+  (when (and (memq 'slime-lisp-mode-hook lisp-mode-hook)
+             (funcall proceed-p))
+    (warn "To restore SLIME in this session, customize `lisp-mode-hook' and
+replace `sly-editing-mode' with `slime-lisp-mode-hook'.")
+    (remove-hook 'lisp-mode-hook 'slime-lisp-mode-hook))
   (dolist (buffer (buffer-list))
     (with-current-buffer buffer
       (when (eq major-mode 'lisp-mode)
-        (sly-editing-mode 1)
-        (ignore-errors (funcall 'slime-mode -1))))))
- (t
-  (warn
-   "`sly.el' loaded OK. To use SLY, customize `lisp-mode-hook' and remove `slime-lisp-mode-hook'.")))
+        (when (and (boundp 'slime-mode) slime-mode (funcall proceed-p))
+          (ignore-errors (funcall 'slime-mode -1)))
+        (sly-editing-mode 1)))))
 
 (provide 'sly)