help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

color coding in emacs


From: Inge
Subject: color coding in emacs
Date: 27 Mar 2006 05:59:50 -0800
User-agent: G2/0.2

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?


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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]