1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
;; itext-mode.el --- a major mode for editing dna sequences
;;
;; ~/lib/emacs/jhg-lisp/itext-mode.el ---
;;
;; $Id: itext-mode.el,v 1.1 2002/12/03 19:18:06 cmungall Exp $
;;
;; Author: harley@bcm.tmc.edu
;; URL: http://www.hgsc.bcm.tmc.edu/~harley/elisp/itext-mode.el
;;
;;; Commentary:
;; --------------------
;; A collection of functions for editing DNA sequences. It
;; provides functions to make editing easier.
;;
;; itext-mode will:
;; * Fontify keywords and line numbers in sequences, but not bases.
;; * Incrementally search dna over pads and numbers
;; * Complement and reverse complement a region.
;; * Move over bases and entire sequences.
;; * Detect sequence files by content.
;;; Installation:
;; --------------------
;; Here are two suggested ways for installing this package.
;; You can choose to autoload it when needed, or load it
;; each time emacs is started. Put one of the following
;; sections in your .emacs:
;;
;; ---Autoload:
;; (autoload 'itext-mode "itext-mode" "Major mode for dna" t)
;; (add-to-list
;; 'auto-mode-alist
;; '("\\.\\(fasta\\|fa\\|exp\\|ace\\|gb\\)\\'" . itext-mode))
;; (add-hook 'itext-mode-hook 'turn-on-font-lock)
;;
;; ---Load:
;; (setq itext-do-setup-on-load t)
;; (load "/pathname/itext-mode")
;;; Code:
;; Setup
(defvar itext-mode-hook nil
"*Hook to setup `itext-mode'.")
(defvar itext-mode-load-hook nil
"*Hook to run when `itext-mode' is loaded.")
(defvar itext-setup-on-load nil
"*If not nil setup itext mode on load by running `itext-`add-hook's'.")
;; I also use "Alt" as C-c is too much to type for cursor motions.
(defvar itext-mode-map
(let ((map (make-sparse-keymap)))
;; Ctrl bindings
(define-key map "\C-cc" 'itext-add-elt)
;; XEmacs does not like the Alt bindings
(cond ((not running-xemacs)
(define-key map [A-right] 'itext-add-elt)))
map)
"The local keymap for `itext-mode'.")
;;;###autoload
(defun itext-mode ()
"Major mode for editing ITEXT.
This mode also customizes isearch to search over line breaks.
\\{itext-mode-map}"
(interactive)
;;
(kill-all-local-variables)
(setq mode-name "itext")
(setq major-mode 'itext-mode)
(use-local-map itext-mode-map)
;;
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(itext-font-lock-keywords))
;;
(make-local-variable 'dna-valid-base-regexp)
(make-local-variable 'dna-sequence-start-regexp)
(make-local-variable 'dna-cruft-regexp)
(make-local-variable 'dna-isearch-case-fold-search)
;;
(run-hooks 'itext-mode-hook)
)
;; Keywords
;; Todo: Seperate the keywords into a list for each format, rather
;; than one for all.
(defvar itext-font-lock-keywords
'(
("\\(\\#.*\\)"
(1 font-lock-comment-face)
)
;; elements
("^ *\\([-_.a-zA-Z_0-9]+\\):"
(1 font-lock-function-name-face)
)
;; others...?
)
"Expressions to hilight in `itext-mode'.")
;;;###autoload
(defun itext-add-hooks ()
"Add a default set of itext-hooks.
These hooks will activate `itext-mode' when visiting a file
which has a itext-like name (.itext) or whose contents
looks like itext. It will also turn enable fontification for `itext-mode'."
(add-hook 'itext-mode-hook 'turn-on-font-lock)
(add-to-list
'auto-mode-alist
'("\\.\\(itext\\|itxt\\)\\'" . itext-mode))
)
;; Setup hooks on request when this mode is loaded.
(if itext-setup-on-load
(itext-add-hooks))
|