From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeckob@gmx.net Newsgroups: gmane.emacs.help Subject: How to create my own mode? Date: 17 Nov 2005 05:56:46 -0800 Organization: http://groups.google.com Message-ID: <1132235806.806274.136230@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1132241293 26981 80.91.229.2 (17 Nov 2005 15:28:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 17 Nov 2005 15:28:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 17 16:28:04 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EclXY-0008MW-Pg for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Nov 2005 16:19:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EclXX-0003TM-Va for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Nov 2005 10:19:08 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 124 Original-NNTP-Posting-Host: 84.168.175.248 Original-X-Trace: posting.google.com 1132235811 15529 127.0.0.1 (17 Nov 2005 13:56:51 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 17 Nov 2005 13:56:51 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 algic:8080 (squid/2.5.STABLE4) Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=84.168.175.248; posting-account=iPNgtw0AAAADVXmtuUc8xtI5c2IiBIhs Original-Xref: shelby.stanford.edu gnu.emacs.help:135521 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:31117 Archived-At: 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