unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: color coding in emacs
Date: Mon, 27 Mar 2006 09:01:52 -0700	[thread overview]
Message-ID: <e092ao$2oc$1@sea.gmane.org> (raw)
In-Reply-To: <1143467990.897885.139600@v46g2000cwv.googlegroups.com>

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

  reply	other threads:[~2006-03-27 16:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-27 13:59 color coding in emacs Inge
2006-03-27 16:01 ` Kevin Rodgers [this message]
     [not found] ` <mailman.35.1143475858.14013.help-gnu-emacs@gnu.org>
2006-03-28  7:33   ` Inge

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='e092ao$2oc$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).