From: Jeckob
Subject: Splitting String
Date: 
Message-ID: <1132060003.865981.132660@g49g2000cwa.googlegroups.com>
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

From: John Thingstad
Subject: Re: Splitting String
Date: 
Message-ID: <op.s0af25h3pqzri1@mjolner.upc.no>
On Tue, 15 Nov 2005 14:06:43 +0100, Jeckob <······@gmx.net> wrote:

This is not CL but elisp.
Perhaps it is more appropriate to ask the question at comp.emacs?
Anyhow the problem goes away if you write it like this :name

Or make it so, then call the algorithm and the reinsert the space.

before:
  (while (re-search-forward  ":\ *" nil nil t) (replace-match ":")
and after:
  (while (re-search-forward ":" nil nil t) (replace-match ": ")))

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


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Jeckob
Subject: Re: Splitting String
Date: 
Message-ID: <1132070970.683426.324000@g44g2000cwa.googlegroups.com>
Thanks !  Appreciate your help...
Cheers