[Top][All Lists]

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

write your own emacs mode

From: Joerg Schuster
Subject: write your own emacs mode
Date: 15 Dec 2003 11:06:14 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2


I "wrote" (i.e. copied and manipulated) an emacs mode with the help of
the following site:

My mode is called grammar-mode, because I use it for editing linguistic
grammars of a certain type. grammar-mode works fine except for one
thing: It uses to mark strings of a certain form as expressions of
type X, although I did not define type X anywhere in the code of
grammar-mode. (Example: Strings that are enclosed in quotes are
displayed with font-lock-string-face. Yet, in the type of files which
I use grammar-mode for, strings of the form '^".*"$' are not
wellformed expressions of any type.) How can I prevent this?

Another question: Is there a (not too complicated) way to replace the
face names like "font-lock-type-face" and so on by more direct
descriptions of the face (e.g. "blue")?


;;;;; Here is the code ;;;;;;;;;;;;

;; grammar-mode
(define-generic-mode 'grammar-mode
  '("adj" "adj4" "adj5" "adjB" "adjb" "adjc" 
    "adjs" "adv" "advb" "advc" "advs" "advv" 
    "advw" "be" "cnj" "cnjK" "cnjS" "det" "deto" 
    "detw" "en" "eng" "have" "infp" "intj" "n" 
    "n4" "ne" "nem" "ng" "nm" "prep" "pron" 
    "pronj" "pronl" "prono" "pronq" "pronw" 
    "tok" "v" "vC" "vD" "vG" "vG3e" "vI" "vP" 
  "Major mode for editing grammar files as used by pm and skonk.")

(defvar grammar-mode-keywords
  '(("[A-Z][^ ]*" . font-lock-type-face)                ; syntactic category
    ("=[a-zA-Z0-9]+" . font-lock-string-face)           ; surface form
    ("_[a-zA-Z0-9]+" . font-lock-string-face)           ; base form
    ("\\^[a-zA-Z0-9]+" . font-lock-string-face)         ; semantic category
    ("[\*\+\?]" . font-lock-function-name-face)         ; *,+,?
    (":" . font-lock-warning-face)))                    ; head symbol

(font-lock-add-keywords 'grammar-mode syntax-mode-keywords)

reply via email to

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