]> git.rkrishnan.org Git - .emacs.d.git/blob - emacs/nxhtml/tests/in/emacswiki-erb-bug.el
submodulized .emacs.d setup
[.emacs.d.git] / emacs / nxhtml / tests / in / emacswiki-erb-bug.el
1 ;;; This file is from a link on EmacsWiki to http://paste.lisp.org/display/59495
2 ;;
3 ;; As far as I can see this is a ruby-mode bug, not a mumamo bug.
4
5 ;;; The problem is that when a ruby ERB template is loaded with an
6 ;;; after-hook that modifies the font-lock keywords, nxhtml causes
7 ;;; font-lock not to occur on strings and comments. What's more is
8 ;;; this affects regular ruby-mode as well, not just within mumamo.
9
10 (require 'ruby-mode)
11
12 ;; Extra keyword fontification for ruby
13 (defun emacswiki-erb-bug-keywords ()
14   (font-lock-add-keywords nil
15                           '(("\\<\\(FIX\\|TODO\\|FIXME\\|HACK\\|REFACTOR\\):"
16                              1 font-lock-warning-face t))))
17
18 ;; Adding the extra keywords at the beginning of ruby-mode-hook breaks
19 ;; ruby-mode fontification (use the test case at the bottom):
20 (add-hook 'ruby-mode-hook 'emacswiki-erb-bug-keywords)
21 ;; removing this hook makes it not break anymore:
22 (remove-hook 'ruby-mode-hook 'emacswiki-erb-bug-keywords)
23 ;; However adding the extra keywords at the end of the hook works fine:
24 (add-hook 'ruby-mode-hook 'emacswiki-erb-bug-keywords t)
25
26
27 ;; run this to test:
28 (progn
29   (find-file "bar.rb")
30   (insert "# Comments should be font-locked, but are not.
31 class Bar
32   def baz
33     \"strings should also be font-locked but are not.\"
34   end
35 end"))
36