joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.26k stars 142 forks source link

rainbow-delimiters-mode does not work with sly #25

Closed Elzair closed 9 years ago

Elzair commented 9 years ago

I have attempted to use rainbow-delimiters in both sly-mrepl-mode and the minor-mode sly-mode, and it does not work in either.

→ emacs --version
GNU Emacs 25.0.50.1
Copyright (C) 2014 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

→ cd /tmp

→ git clone https://github.com/capitaomorte/sly.git
Cloning into 'sly'...
remote: Counting objects: 23123, done.
remote: Compressing objects: 100% (431/431), done.
remote: Total 23123 (delta 284), reused 0 (delta 0)
Receiving objects: 100% (23123/23123), 15.59 MiB | 1.92 MiB/s, done.
Resolving deltas: 100% (16577/16577), done.
Checking connectivity... done.

→ cd sly 

→ wget https://raw.githubusercontent.com/jlr/rainbow-delimiters/master/rainbow-delimiters.el
--2014-10-23 16:06:29--  https://raw.githubusercontent.com/jlr/rainbow-delimiters/master/rainbow-delimiters.el
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 23.235.40.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|23.235.40.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23873 (23K) [text/plain]
Saving to: ‘rainbow-delimiters.el’

100%[==========================================================================================================================================================================>] 23,873      --.-K/s   in 0.03s   

2014-10-23 16:06:29 (928 KB/s) - ‘rainbow-delimiters.el’ saved [23873/23873]

→ echo $(git log -1 --oneline)
5e9b831 Can't use Gray streams for ABCL

→ emacs -q -nsl 

I then executed the following elisp code with M-:

(add-to-list 'load-path "/tmp/sly")
(require 'sly)
(require 'rainbow-delimiters)

I then started the sly-mrepl (with M-x sly) and attempted to turn on rainbow-delimiters (with M-: (rainbow-delimiters-mode-turn-on)), but nothing happened.

joaotavora commented 9 years ago

Thanks for the very detailed bug report. I'm sure I will be able to reproduce and get back to you with an answer, maybe a fix.

joaotavora commented 9 years ago

@Elzair, I've analysed this problem. First of all, rainbow-delimiters-mode does work in lisp-mode, that is, lisp files. Can you confirm this?

I have confirmed it does not work in sly-mrepl-mode.

The reason for that is that sly-mrepl-mode does not use font-lock-mode, which rainbow-delimiters-mode requires. This is technically a limitation in rainbows-delimiters so I've removed the "bug" tag from this issue.

That said, there is a workaround. In the hook where you would normally turn on rainbow-delimiters-mode, make sure font-lock-mode is activated before.

(defun sly-mrepl-turn-on-rainbow-delimiters ()
  (font-lock-mode 1)
  (rainbow-delimiters-mode 1))
(add-hook 'sly-mrepl-mode-hook 'sly-mrepl-turn-on-rainbow-delimiters 'append)

rainbow-delimiters will start working. Some faces will be changed, but I can minimize that with a future commit. In my tests in Emacs 24.4 everything works:

coiso

However in 24.3 you might run into problems. See issue #1.

Elzair commented 9 years ago

Well, I added (font-lock-mode 1) to my sly-mrepl-mode-hook, and everything works fine in both lisp-mode and sly-mrepl-mode. Thank you!