[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to create my own mode?
From: |
Jeckob |
Subject: |
How to create my own mode? |
Date: |
17 Nov 2005 05:56:46 -0800 |
User-agent: |
G2/0.2 |
Hi, i have written some functions in elisp to get some strings
formated. Now i want to have that only active when i open *.ci
files....how can i do this in elisp? Here is my code:
(defun pre-process-words (words)
(loop
with result = '()
while words
do (if (string= ":" (first words))
(progn
(push (format "%s %s" (first words) (second words))
result)
(setf words (cddr words)))
(progn
(push (first words) result)
(setf words (cdr words))))
finally (return (nreverse result))))
(defun format/align-and-newline ()
(interactive)
(let* ((anker (point))
(start (progn (beginning-of-line) (point)))
(end (progn (end-of-line) (point)))
(line (buffer-substring start end))
(words (pre-process-words (split-string line))))
(setq testpoint (first words))
(setq doppeltab 57)
(setq tabFlag 0)
(setq merker1 0)
(setq kreuzFlag 0)
(setq doppelFlag 0)
(when (position ?+ (first words))
(progn
(setq kreuzFlag 1)
(previous-line 1)
(beginning-of-line)
(setq start (point))
(end-of-line)
(setq end (point))
(setq line (buffer-substring start end))
(next-line 1)
(beginning-of-line)
(when (or (position ?: line) (position ?+ line) )
(progn
(setq doppelFlag 1)
(setq start (point))
(end-of-line)
(setq end (point))
(setq line (buffer-substring start end))
(setq words (split-string line))
(beginning-of-line)
(forward-char 1)
(setq start (point))
(delete-region start end)
(move-to-column 59 t)
(insert (format "%-17s" (second words)))
(insert "\n")
))
(when (= doppelFlag 0)
(progn
(end-of-line)
(insert "\n")
))))
(when (= kreuzFlag 0)
(progn
(if (setq posDoppel (position ?: line) )
(if (position ?. testpoint)
(insert "\n")
(delete-region start end)
(insert (format "%-10s" (first words)))
(setq wortLaenge (length (first words)))
(when (> wortLaenge 9)
(progn
(insert " ")
))
(dolist (word (cdr words))
(if (position ?: word)
(progn
(if (= tabFlag 0)
(progn
(when (> merker1 doppeltab)
(progn
(setq doppeltab merker1)
))
(move-to-column doppeltab t)
(insert (format "%-17s" word))
(setq wortLaenge (length word))
(when (> wortLaenge 16)
(progn
(insert " ")
))
(setq tabFlag 1)
)
(progn
(insert (format "%-17s" word))
(setq wortLaenge (length word))
(when (> wortLaenge 16)
(progn
(insert " ")
))
)))
(progn
(insert (format "%-10s" word))
(setq wortLaenge (length word))
(when (> wortLaenge 9)
(progn
(insert " ")
))
(setq merker1 (current-column))
)))
(if (beginning-of-line)
(insert "\n")
(setq anker (point)))
))
(goto-char anker)
(when (= tabFlag 1)
(progn
(end-of-line)
))
(insert "\n")
))))
Thanks
- How to create my own mode?,
Jeckob <=