help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble fontifying /** ... */


From: Davin Pearson
Subject: Re: Trouble fontifying /** ... */
Date: Tue, 13 Jan 2009 19:18:16 -0800 (PST)
User-agent: G2/1.0

On Jan 10, 2:21 am, Xah Lee <address@hidden> wrote:
> On Jan 8, 8:54 pm, Davin Pearson <address@hidden> wrote:
>
> > I have invented a language called SJS that it a mixture of Pascal and
> > Java for easier learning of the Java language.  In sjs-mode
> > I would like the following code:
>
> > /**
> >   I am a Javadoc-style comment.
> > */
>
> > To be fontified in font-lock-doc-face but I cannot find an elegant way
> > to do this.  What follows is some Emacs version information,
> > via report-emacs-bug:
>
> your question is a FAQ but without much polished answer.

Here is my existing code.  The trouble with it is
that it sometimes highlights the keyword end in font-lock-type-face.
This is a problem with inheriting from the java major mode.

(defun sjs-mode
()
 
(interactive)
  (font-lock-mode
0)
  (kill-all-local-
variables)
  (java-
mode)

  (setq major-mode 'sjs-
mode)
  (setq mode-name
"SJS")

  (set-syntax-table sjs-mode-syntax-
table)
  (use-local-map sjs-mode-
map)

  (local-set-key "\t" 'sjs--
tab)

  (local-set-key [(meta control \\)] 'sjs--meta-control-
backslash)

  (abbrev-mode
1)
  (setq local-abbrev-table java-mode-abbrev-
table)

  (font-lock-add-
keywords
 
nil
 
'(
     ("\\<\\(assert\\|begin\\|end\\|function\\|var\\|classVar\\|
instanceVariable\\|property\\|method\\|constructor\\|until\\|then\\|and
\\|or\\)\\>" (1 'font-lock-keyword-face nil))

     ("\\<\\(beginMain\\|endMain\\)\\>" 0 'font-lock-keyword-face
nil)

     ("\\<\\(null\\|true\\|false\\)\\>" 1 'font-lock-constant-face
nil)

     ("\\<\\(abstract\\|break\\|byte\\|case\\|catch\\|class\\|const\\|
continue\\|default\\|do\\|else\\|extends\\|final\\|finally\\|for\\|goto
\\|if\\|implements\\|import\\|instanceof\\|interface\\|native\\|new\\|
package\\|private\\|protected\\|public\\|return\\|static\\|super\\|
switch\\|synchronized\\|this\\|throw\\|throws\\|transient\\|try\\|
volatile\\|while\\|null\\)\\>" 1 'font-lock-keyword-face nil)


      ("\\<function [^ ]* \\([a-z][A-Za-z0-9_]*\\)" 1 'font-lock-
function-name-face nil)
      ("\\<method [^ ]* \\([a-z][A-Za-z0-9_]*\\)" 1 'font-lock-
function-name-face nil)

      ("\\<\\([A-Z]+[a-z][A-Za-z0-9]*\\|[A-Z]\\|boolean\\|char\\|int\\|
long\\|short\\|float\\|double\\)[][]*[ \t]+\\([a-z][A-Za-z0-9]*\\)"
       (1 'font-lock-type-face
nil)
       (2 'font-lock-variable-name-face
nil))

      ("\\<[A-Z]+[a-z][A-Za-z0-9_]*" 0 'font-lock-type-face
nil)
      ("\\<[A-Z]\\>" 0 'font-lock-type-face
nil)
      ("\\<\\(boolean\\|char\\|int\\|long\\|short\\|float\\|double\\|
void\\)\\>" 0 'font-lock-type-face nil t)

     ))


  (font-lock-mode
3)

  )

> If your comment syntax is more complex, you cannot use syntax table
> for it. You have to use font-lock-syntactic-keywords, and also you'll
> need to implement your own comment-dwim.

> • How To Add Comment Handling In Your Major Mode
>  http://xahlee.org/emacs/elisp_comment_handling.html
>
> See also Rick (rgb)'s experience, at
>
>http://groups.google.com/group/gnu.emacs.help/browse_frm/thread/465e9...
>
>http://groups.google.com/group/comp.emacs/browse_frm/thread/c1b7de448...

Could you give me some more information as to how to proceed. I am
stuck.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]