Discussion:
emacs mode writing
(too old to reply)
macsaint
2006-11-20 00:16:48 UTC
Permalink
Hello

I am writing an emacs mode for a house-made software at my company.

It seems to work, but the comment highlighting is not working.
/* blah blah */ or C in the first column need to be recognized
as comments.

Pls.. help me.

macsaint



(defvar flex-font-lock-keywords
`((,(concat "\\<"
(regexp-opt '("abls" "axis" "bar" "bmat" "bm3d" "bond" "boun" "calc"
"circ" "data" "drlx" "echo" "exam" "exec" "extr" "ffld" "func" "gcon" "geom"
"glue" "grav" "grid" "grph" "heat" "intr" "isln" "job" "ldef" "line" "linr"
"magn" "mass" "matr" "mbrn" "mem" "membrane" "mgr" "modl" "mods" "mp" "old"
"outp" "piez" "plod" "pnbl" "pout" "pplt" "prcs" "prnt" "regrid" "rest"
"riera" "rigd" "set" "shap" "shel" "show" "site" "stop" "term" "time" "titl"
"trns" "user" "watr" "wndo" "xfil" "zone") t)
"\\>") (0 font-lock-keyword-face))
(,(concat "\\<"
(regexp-opt '("prop" "sect" "elem" "gcon" "del" "out1" "node" "plot"
"eye" "vert" "clos" "end" "type" "rate" "hist" "xcrd" "ycrd" "zcrd" "regn"
"grup" "optn" "erod" "gend" "tinc" "vpnt" "bc" "fix" "skew" "defn" "rnod"
"csec" "pdef" "sdef" "vctr") t)
"\\>") (0 font-lock-function-name-face))
(,(concat "\\<"
(regexp-opt '("symb") t)
"\\>") (0 font-lock-string-face))
"Keyword highlighting specification for `flex-mode'.")

(define-derived-mode flex-mode fundamental-mode "FLEX"
"A major mode for editing .flex files."
(make-local-variable 'comment-start)
(setq comment-start "/* ")
(make-local-variable 'comment-end)
(setq comment-end " */")
(set (make-local-variable 'font-lock-defaults)
'(flex-font-lock-keywords))
)

(setq major-mode 'flex-mode)
(setq mode-name "FLEX")
(local-set-key "\t" " ") ;; define tab key
(run-hooks 'flex-mode-hook)

(provide 'flex-mode)
Markus Triska
2006-11-20 17:51:52 UTC
Permalink
Post by macsaint
It seems to work, but the comment highlighting is not working.
/* blah blah */ or C in the first column need to be recognized
as comments.
Add this to the definition of flex-mode:

(let ((table (make-syntax-table)))
(modify-syntax-entry ?* ". 23b" table)
(modify-syntax-entry ?/ ". 14" table)
(modify-syntax-entry ?C "<" table)
(modify-syntax-entry ?\n ">" table)
(set-syntax-table table))

All the best!
Markus Triska

Continue reading on narkive:
Loading...