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

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

Re: How to enable the syntax highlighting for comments within files havi


From: bj
Subject: Re: How to enable the syntax highlighting for comments within files having a specific extension?
Date: Thu, 16 Jul 2009 06:13:11 -0700 (PDT)
User-agent: G2/1.0

Dear Xah,

Thanks for your help.

I have partly reached my goals.

Here is the jou-mode.el file which I built on the basis of your
tutorials:

<--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---
><--8---><--8---><--8--->
;; the command to comment/uncomment text
(defun jou-comment-dwim (arg)
   "Comment or uncomment current line or region in a smart way. For
detail, see `comment-dwim'."
   (interactive "*P")
   (require 'newcomment)
   (let ((deactivate-mark nil) (comment-start "/") (comment-end ""))
     (comment-dwim arg)))

(setq myKeywords
 `(
  )
)

;; define the major mode.
(define-derived-mode jou-mode fundamental-mode
  "you are in jou-mode"
  (setq font-lock-defaults '(myKeywords))

  (setq comment-start "/")

  (define-key jou-mode-map [remap comment-dwim] 'jou-comment-dwim)

  (modify-syntax-entry ?/ "< b" jou-mode-syntax-table)
  (modify-syntax-entry ?\n "> b" jou-mode-syntax-table)
)
<--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---
><--8---><--8---><--8--->


The comment syntax highlighting works, but I still have few questions.


1) Is the line (setq comment-start "/") which I have added really
needed?

2) I don't need the keywords, but if I remove the relevant entries in
the jou-mode.el file
   (i.e. lines 9-12, 17), the commented lines are no longer in red.

3) if the comment string "/" is in the middle of a line, like the
division sign in an expression,
   then the characters to the right of it are turned into red. Do you
know how to avoid this?

Thanks for your help

gento




reply via email to

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