all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: random color of variables in programming languages
Date: Thu, 12 Dec 2013 22:05:22 +0100	[thread overview]
Message-ID: <87y53p4w5w.fsf@nl106-137-194.student.uu.se> (raw)
In-Reply-To: mailman.9022.1386861695.10748.help-gnu-emacs@gnu.org

Luca Ferrari <fluca1978@infinito.it> writes:

> Using the variable name is a good idea, even if names
> could easily produce a clash.  However, any
> suggestion on where to start (in elisp code) for
> variable font face?

To setup the faces of a major mode, the way I did it
was to first define the faces, then setup regular
expressions (in groups), and then hook those groups to
faces. If there isn't any groups (or just one,
perhaps), you don't have to use the digits to hook the
groups, but can use the dotted pair notation (check out
fpscalc-comment below).

However, I am unsure if this can be twisted to do
"dynamic faces".

If not, we'll have to move closer to where actual
coloring is done. Does the Emacs idle-timer invoke
that?  Could you insert something in between?

Or what about a hook for each completed word? Or would
that be too slow?

;; ... the other faces

(defface fpscalc-semaphore-name
  '((t :inherit font-lock-variable-name-face :background "black" :foreground "yellow" :bold t))
  "The word after the word semaphore, after the left parenthesis."
  )

(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))
    ))

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


  parent reply	other threads:[~2013-12-12 21:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.8911.1386765750.10748.help-gnu-emacs@gnu.org>
2013-12-11 16:06 ` random color of variables in programming languages Emanuel Berg
2013-12-12 15:21   ` Luca Ferrari
     [not found]   ` <mailman.9022.1386861695.10748.help-gnu-emacs@gnu.org>
2013-12-12 21:05     ` Emanuel Berg [this message]
2013-12-20  1:36     ` Emanuel Berg
2013-12-23 14:51       ` Luca Ferrari
     [not found]       ` <mailman.10142.1387810292.10748.help-gnu-emacs@gnu.org>
2013-12-24 19:31         ` Emanuel Berg
2013-12-11 12:42 Luca Ferrari

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

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

  git send-email \
    --in-reply-to=87y53p4w5w.fsf@nl106-137-194.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.