From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luca Ferrari Newsgroups: gmane.emacs.help Subject: Re: random color of variables in programming languages Date: Mon, 23 Dec 2013 15:51:26 +0100 Message-ID: References: <87txefid7c.fsf@nl106-137-194.student.uu.se> <87ppos2tie.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1387810299 19011 80.91.229.3 (23 Dec 2013 14:51:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Dec 2013 14:51:39 +0000 (UTC) Cc: help-gnu-emacs To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 23 15:51:43 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vv6r9-0005KA-FH for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Dec 2013 15:51:43 +0100 Original-Received: from localhost ([::1]:33962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vv6r8-0000jC-VE for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Dec 2013 09:51:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vv6qv-0000iG-TK for help-gnu-emacs@gnu.org; Mon, 23 Dec 2013 09:51:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vv6qu-0001er-Dn for help-gnu-emacs@gnu.org; Mon, 23 Dec 2013 09:51:29 -0500 Original-Received: from mail-we0-x22b.google.com ([2a00:1450:400c:c03::22b]:48899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vv6qu-0001eg-6e for help-gnu-emacs@gnu.org; Mon, 23 Dec 2013 09:51:28 -0500 Original-Received: by mail-we0-f171.google.com with SMTP id q58so4923979wes.2 for ; Mon, 23 Dec 2013 06:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=XLRc0yTDR72fYyLW5+64PlZcUPhOcV/ltNEu6T+ShtE=; b=VGDnIdgDXzDm3hVe98x/aCIogysNHqYIDSMdCwTowA48IMwZiERMJl9eWJAdrw74Fm s/3dUI8gotQvtXVTx7bXOcQkYcKel41Jj/701o3ptG6hjknE0d606vh9+4xp1WhvtScI UakgS7z0vx4qBPd9Jn2vjNzC2IZxvPiyTutdxw7Tgf+NdwvblLJIQXxh+N8j6zZ8FCDA zL4J0noVme+CKQyyd1eD2CVPhNKiV2CEE9kUhO05l3sPJmCLVtiO7FhdrzztW4owPXg9 zLols+s8yQPLTog3eBgsufZzOxCIv/9FzHW0De/3sWfrsa2onbRaZ6Y11mkoQaGICCGs xZ7w== X-Received: by 10.194.178.166 with SMTP id cz6mr1947837wjc.53.1387810286360; Mon, 23 Dec 2013 06:51:26 -0800 (PST) Original-Received: by 10.194.75.137 with HTTP; Mon, 23 Dec 2013 06:51:26 -0800 (PST) In-Reply-To: <87ppos2tie.fsf@nl106-137-194.student.uu.se> X-Google-Sender-Auth: lJqKEmjQpRn3lmVKGMP52vsJp08 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22b X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95136 Archived-At: On Fri, Dec 20, 2013 at 2:36 AM, Emanuel Berg wrote: > Luca Ferrari 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