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

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

Re: Basic font-lock without font-locking double-quoted strings


From: Emanuel Berg
Subject: Re: Basic font-lock without font-locking double-quoted strings
Date: Fri, 20 Dec 2013 01:26:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Joe Riel <joer@san.rr.com> writes:

> Why would the following minimal mode
>
> (define-derived-mode msdbg-mode fundamental-mode (setq
> font-lock-keywords '(("EA"
> . font-lock-warning-face))))

Does that work at all?

According to the help, it should look like this:

(define-derived-mode article-mode sgml-mode "Article"
  "Major mode for editing technical articles."
  (setq case-fold-search nil))

But strings are highlighted in fundamental-mode
(font-look-face-face) so at least that makes sense.

You'll have to wait for a better answer, but the below
code (the only mode I did) might interest you. When I
did it, I was told on this list not to make it a
generic mode but to derive from fundamental-mode,
however, I didn't do that - first the keywords, then
create the mode.

(defvar fpscalc-keywords
  '(("\\(!.*$\\)" . 'fpscalc-comment)
    ("\\(semaphore\\)\\((\\)\\([[:word:]]+\\)\\(\\, \\)\\([[:word:]]+\\)"
     (1 'fpscalc-semaphore-keyword)
     (3 'fpscalc-semaphore-name)
     (5 'fpscalc-task-name-and-index) )
    ("declarations\\|initialise\\|semaphores\\|formulas" . 
'fpscalc-program-parts)
    ("sigma\\|floor\\|ceiling\\|min\\|max" . 'fpscalc-math-functions)
    ("lp\\|ep\\|hp\\|all" . 'fpscalc-task-priority-sets)
    ("\\([[:word:]]\\)\\(\\[\\)\\(i\\)\\(\\]\\)"
     (1 'fpscalc-variable-name)
     (3 'fpscalc-i-task) )
    ("\\([[:word:]]\\)\\(\\[\\)\\(j\\)\\(\\]\\)"
     (1 'fpscalc-variable-name)
     (3 'fpscalc-j-task))
    ("\\([[:word:]]\\)\\(\\[\\)\\(.*\\)\\(\\]\\)"
     (1 'fpscalc-variable-name)
     (3 'fpscalc-task-name-and-index))
    ("\\(system \\)\\(.* \\)"
     (1 'fpscalc-system-keyword)
     (2 'fpscalc-system-name))
    ("\\(scalar\\|indexed\\|priority\\|blocking\\)\\( 
\\)+\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
     (1 'fpscalc-variable-type)
     (3 'fpscalc-variable-name))
    ("\\(tasks +\\)\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
     (1 'fpscalc-tasks-keyword)
     (2 'fpscalc-task-name-and-index))
    ))

(define-generic-mode
    'fpscalc-mode
  '("!")
  nil
  fpscalc-keywords
  '("\\.fps\\'")
  '((lambda ()
      (progn
        (setq indent-line-function 'fpscalc-indent-line)
        (local-set-key "\C-c\C-c" 'compute) )))
  "Major mode for .fps files and the fpscalc tool.")

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

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