unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Inge" <Inge.v.d.Berg@gmail.com>
Subject: color coding in emacs
Date: 27 Mar 2006 05:59:50 -0800	[thread overview]
Message-ID: <1143467990.897885.139600@v46g2000cwv.googlegroups.com> (raw)

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	other threads:[~2006-03-27 13:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-27 13:59 Inge [this message]
2006-03-27 16:01 ` color coding in emacs Kevin Rodgers
     [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=1143467990.897885.139600@v46g2000cwv.googlegroups.com \
    --to=inge.v.d.berg@gmail.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).