all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jeckob@gmx.net
Subject: How to create my own mode?
Date: 17 Nov 2005 05:56:46 -0800	[thread overview]
Message-ID: <1132235806.806274.136230@f14g2000cwb.googlegroups.com> (raw)

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

             reply	other threads:[~2005-11-17 13:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 13:56 Jeckob [this message]
2005-11-17 16:40 ` How to create my own mode? Pascal Bourguignon
2005-11-17 18:04   ` Henrik Enberg
     [not found]   ` <mailman.15669.1132250677.20277.help-gnu-emacs@gnu.org>
2005-11-18 10:23     ` Jeckob
2005-11-18 15:07       ` Pascal Bourguignon
2005-11-21 11:12         ` Jeckob

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1132235806.806274.136230@f14g2000cwb.googlegroups.com \
    --to=jeckob@gmx.net \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.