开发者

Font Problem in Emacs

I'm going to be spending some time working in Habenero Java, a minor variant of regular Java, and to make my life easier, I'm trying to define an Emacs mode to work with it.

Right now, all I'm trying to do is define a new major mode that inherits from Java and adds three new keywords: finish, async, and forall. This is what I have so far:

(define-derived-mode hj-mode java-mode "Habanero Java"
  "Major mode for Habanero Java."
  (font-lock-add-keywords nil `((,(regexp-opt '("finish" "async" "forall")) .
     font-lock-keyword-face))))

The problem I'm having is that Emacs apparently cannot disting开发者_开发技巧uish between these new keywords and a variable declaration. If I write async { x(); } then Emacs highlights it correctly. But if I write the equivalent async x();, then Emacs fontifies it as if I were declaring a variable by the name async.

Does anyione know how to resolve this? The frustration over this is killing me.


One way is to change your keyword element to the (matcher . subexp-highlighter) format where subexp is 0 and override is t:

(font-lock-add-keywords nil `((,(regexp-opt '("finish" "async" "forall"))
   0 font-lock-keyword-face t)

More information can be found at: http://www.gnu.org/software/emacs/manual/html_node/elisp/Search_002dbased-Fontification.html#Search_002dbased-Fontification

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜