all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <spam@mouse-potato.com>
Subject: Re: Get Text from Current Line
Date: Wed, 09 Nov 2005 17:34:22 +0100	[thread overview]
Message-ID: <87br0t4w6p.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: 1131546587.320054.206100@g43g2000cwa.googlegroups.com

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

  reply	other threads:[~2005-11-09 16:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-09 14:29 Get Text from Current Line Jeckob
2005-11-09 16:34 ` Pascal Bourguignon [this message]
2005-11-11 10:22   ` Jeckob
2005-11-11 12:41     ` 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=87br0t4w6p.fsf@thalassa.informatimago.com \
    --to=spam@mouse-potato.com \
    /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.