From: Luca Ferrari <fluca1978@infinito.it>
To: Emanuel Berg <embe8573@student.uu.se>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: random color of variables in programming languages
Date: Mon, 23 Dec 2013 15:51:26 +0100 [thread overview]
Message-ID: <CAKoxK+4RJ+=aAhtQEvEyiwF9c8kcu-DtMCvHdU+SKqSHFtkNoQ@mail.gmail.com> (raw)
In-Reply-To: <87ppos2tie.fsf@nl106-137-194.student.uu.se>
On Fri, Dec 20, 2013 at 2:36 AM, Emanuel Berg <embe8573@student.uu.se> wrote:
> Luca Ferrari <fluca1978@infinito.it> writes:
>
>> any suggestion on where to start (in elisp code) for
>> variable font face?
>
> Cool dump: http://user.it.uu.se/~embe8573/colvar.png
>
> (save-excursion
> (require 'thingatpt) ; word-at-point
> (if (search-forward-regexp "defvar " (point-max) t)
> (let*((var-name (word-at-point))
> (color-code (car (string-to-list var-name)))
> (the-face (if (= color-code 114) ; if it starts with 'r'
> 'font-lock-warning-face ; use this face
> 'font-lock-variable-face)) )
> (font-lock-add-keywords
> 'emacs-lisp-mode
> `((,var-name . ,the-face)))
> (emacs-lisp-mode) ))) ; <-- hit this
>
> (defvar red 1)
> (defvar another-variable 4)
>
> (if (= red 1) t nil)
Very good example, thanks.
Luca
next prev parent reply other threads:[~2013-12-23 14:51 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
2013-12-20 1:36 ` Emanuel Berg
2013-12-23 14:51 ` Luca Ferrari [this message]
[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='CAKoxK+4RJ+=aAhtQEvEyiwF9c8kcu-DtMCvHdU+SKqSHFtkNoQ@mail.gmail.com' \
--to=fluca1978@infinito.it \
--cc=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.