unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Get Text from Current Line
@ 2005-11-09 14:29 Jeckob
  2005-11-09 16:34 ` Pascal Bourguignon
  0 siblings, 1 reply; 4+ messages in thread
From: Jeckob @ 2005-11-09 14:29 UTC (permalink / raw)


Hi,
i would like to write some code in emacs-lisp to format/align the
current line in a spec. way each time the editor jumps to the
next/other line.
i.e.
when i type:

abc xyz kfx uzr ert : ert : oiu

the editor should format it the moment i type enter or nextline (arrow
down) this way:

abc       xyz       kfx       uzr       ert       : ert       : oiu

and so on....

How can i realize this? Pls give me a hint, dont how to start !?
Thanks

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

* Re: Get Text from Current Line
  2005-11-09 14:29 Get Text from Current Line Jeckob
@ 2005-11-09 16:34 ` Pascal Bourguignon
  2005-11-11 10:22   ` Jeckob
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Bourguignon @ 2005-11-09 16:34 UTC (permalink / raw)


Jeckob@gmx.net writes:

> Hi,
> i would like to write some code in emacs-lisp to format/align the
> current line in a spec. way each time the editor jumps to the
> next/other line.
> i.e.
> when i type:
>
> abc xyz kfx uzr ert : ert : oiu
>
> the editor should format it the moment i type enter or nextline (arrow
> down) this way:
>
> abc       xyz       kfx       uzr       ert       : ert       : oiu
>
> and so on....
>
> How can i realize this? Pls give me a hint, dont how to start !?

As a starting point you may use this (untested code):

(defun format/align-and-newline ()
   (interactive)
   (let* ((start (progn (beginning-of-line) (point)))
          (end   (progn (end-of-line) (point)))
          (line (buffer-substring start end))
          (words (split-string line)))
      (delete-region start end)
      (insert (first words))
      (dolist (word (cdr words))
         (insert (format "%*s%s" 6 "" word))) ; you want something else here.
      (insert "\n")))

(local-set-key (kbd "RET") (function format/align-and-newline))



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Cats meow out of angst
"Thumbs! If only we had thumbs!
We could break so much!"

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

* Re: Get Text from Current Line
  2005-11-09 16:34 ` Pascal Bourguignon
@ 2005-11-11 10:22   ` Jeckob
  2005-11-11 12:41     ` Jeckob
  0 siblings, 1 reply; 4+ messages in thread
From: Jeckob @ 2005-11-11 10:22 UTC (permalink / raw)


Thanks, for your help. Will try it...

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

* Re: Get Text from Current Line
  2005-11-11 10:22   ` Jeckob
@ 2005-11-11 12:41     ` Jeckob
  0 siblings, 0 replies; 4+ messages in thread
From: Jeckob @ 2005-11-11 12:41 UTC (permalink / raw)


Tryed it, and it works fine! Thanks again...
But now i have another question? How can i proof something in one line
before/after the current line, or two lines before/after the current
line and so on...thnaks in advance

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

end of thread, other threads:[~2005-11-11 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-09 14:29 Get Text from Current Line Jeckob
2005-11-09 16:34 ` Pascal Bourguignon
2005-11-11 10:22   ` Jeckob
2005-11-11 12:41     ` 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).