From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: color coding in emacs Date: Mon, 27 Mar 2006 09:01:52 -0700 Message-ID: References: <1143467990.897885.139600@v46g2000cwv.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1143475915 5205 80.91.229.2 (27 Mar 2006 16:11:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 27 Mar 2006 16:11:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 27 18:11:53 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FNuJK-0002fk-Q7 for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Mar 2006 18:11:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FNuJK-0002qP-9u for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Mar 2006 11:11:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FNuIy-0002pz-PE for help-gnu-emacs@gnu.org; Mon, 27 Mar 2006 11:10:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FNuIx-0002pn-8L for help-gnu-emacs@gnu.org; Mon, 27 Mar 2006 11:10:56 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FNuIx-0002pk-66 for help-gnu-emacs@gnu.org; Mon, 27 Mar 2006 11:10:55 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FNuKT-0001bQ-Rw for help-gnu-emacs@gnu.org; Mon, 27 Mar 2006 11:12:30 -0500 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1FNuIe-0002XE-9I for help-gnu-emacs@gnu.org; Mon, 27 Mar 2006 18:10:36 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Mar 2006 18:10:36 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Mar 2006 18:10:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 59 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <1143467990.897885.139600@v46g2000cwv.googlegroups.com> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:34008 Archived-At: Inge wrote: > hi > i frequently use a text editor to view some files containing DNA info. > These are just simply a great number of lines of characters, the > characters can be A,C,G or T. At the moment I would like to have the > text color coded, so that each A has one color, each C has another > color, etc. Since emacs is my favorite editor I wanted to start and see > if emacs could do it for me. > However, I am having some difficulties. I thought about creating a new > major mode and use font-lock. But somehow this doesn't work. The mode > is recognised, but there is no highlighting or coloring. It does work > when I manually use hi-lock, but I want the coloring pattern saved > outside of the file. > Can anyone tell me if this is at all doable with emacs? Googling for emacs and dna yields many results, including http://www.mahalito.net/~harley/elisp/dna-mode.el > To my .emacs (init) file I added the lines: > ;; load mode file for fasta mode > (require 'fasta-mode "/home/ivdberg/customize/fasta-mode.el") > > (add-to-list 'auto-mode-alist '("\\.fa\\'" . fasta-mode)) > (add-to-list 'auto-mode-alist '("\\.fasta\\'" . fasta-mode)) > > Fasta-mode.el looks like this: > ;; fasta-mode.el > ;; mode inteded for automatic highlighting of fasta files > > (defvar fasta-mode-hook nil) > > (defconst fasta-font-lock-keywords > (list > '("A" . "Yellow") > '("C" . "Green") > '("G" . "Blue") > '("T" . "Pink")) > ) > > (defun fasta-mode () > "Major mode for highlighting fasta files" > (interactive) > (kill-all-local-variables) > > (set (make-local-variable 'font-lock-defaults) > '(fasta-font-lock-keywords)) > > (setq major-mode 'fasta-mode) > (setq mode-name "Fasta") > (run-hooks 'fasta-mode-hook) > ) > > (provide 'fasta-mode) If you want to roll your own, see http://www.emacswiki.org/cgi-bin/wiki/CreateNewMajorMode -- Kevin Rodgers