|
From: | Kevin Rodgers |
Subject: | Re: color coding in emacs |
Date: | Mon, 27 Mar 2006 09:01:52 -0700 |
User-agent: | Mozilla Thunderbird 0.9 (X11/20041105) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |