unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Splitting String
@ 2005-11-15 12:17 Jeckob
  2005-11-15 13:09 ` Pascal Bourguignon
  0 siblings, 1 reply; 3+ messages in thread
From: Jeckob @ 2005-11-15 12:17 UTC (permalink / raw)


Hi all,
having problems with some Code i have written, half of the job is done
but now i have problems to get on. here is me code until now :

(defun format/align-and-newline ()
  (interactive)
  (setq anker (point))
  (let* ((start (progn (beginning-of-line) (point)))
	 (end   (progn (end-of-line) (point)))
	 (line (buffer-substring start end))
	 (words (split-string line)))
    (setq testpoint (first words))
    (if (setq posDoppel (position ?: line) )
	(if (position ?. testpoint)
	    (insert "\n")
	   (delete-region start end)
	  (insert (format "%-10s" (first words)))
	  (dolist (word (cdr words))
	    (insert (format "%-10s" word)))
	  (if (beginning-of-line)
	      (insert "\n")
	    (setq anker (point)))
	  )
      )
    )
  (goto-char anker)
  (insert "\n")
  )
 (local-set-key (kbd "RET") (function format/align-and-newline))
;;end

If i type a line like this:
abc def ghj klm : nop : qrs : tuv

the code transforms the string to:
abc       def       ghj       klm       :         nop       :
qrs       :         tuv

So, the thing im having problems is to get the string like this :
abc       def       ghj       klm       : nop     : qrs     : tuv

in other words, if there is a colon typed a space before a word, i need
to have the colon with the word to be in the cell of the list, and not
the colon alone as a word. So, in the example the list should have 7
elements and not 10. Maybe somebody can give me a hint... thanks in
advance 
greets

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-15 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-15 12:17 Splitting String Jeckob
2005-11-15 13:09 ` Pascal Bourguignon
2005-11-15 14:46   ` Jeckob

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).