[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: random color of variables in programming languages
From: |
Luca Ferrari |
Subject: |
Re: random color of variables in programming languages |
Date: |
Mon, 23 Dec 2013 15:51:26 +0100 |
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