unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Joerg Schuster <js@cis.uni-muenchen.de>
Subject: write your own emacs mode
Date: 15 Dec 2003 11:06:14 +0100	[thread overview]
Message-ID: <crtoeuajsyx.fsf@pinatubo.cis.uni-muenchen.de> (raw)

Hello,

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

http://www.emacswiki.org/cgi-bin/wiki.pl/GenericMode

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")?

Jörg



;;;;; 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" 
    "vV")
  nil
  '(".syn$")
  nil
  "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	other threads:[~2003-12-15 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-15 10:06 Joerg Schuster [this message]
2003-12-15 12:37 ` write your own emacs mode Jesper Harder
2003-12-16 10:05   ` Joerg Schuster
2003-12-16 12:37     ` Jesper Harder
2003-12-16 13:06       ` Joerg Schuster
2003-12-16 13:51   ` F. Schaefer
2003-12-16 14:21     ` Joerg Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=crtoeuajsyx.fsf@pinatubo.cis.uni-muenchen.de \
    --to=js@cis.uni-muenchen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).