all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Customising fill-paragrah
Date: Tue, 10 Feb 2009 06:10:03 -0800 (PST)	[thread overview]
Message-ID: <0012f3e9-3378-4714-9c82-14d2a7e3837f@z27g2000prd.googlegroups.com> (raw)
In-Reply-To: mailman.283.1234252813.31690.help-gnu-emacs@gnu.org

On Feb 10, 12:02 am, Sebastian Tennant <seb...@smolny.plus.com> wrote:
> Hi All,
>
> I'd like to be able to fill (M-q) a paragraph that begins with a colon
> (in column 0) followed by three SPC chars, without it reducing the three
> spaces to one, i.e., so that I can type M-q on the example para below
> without it having any affect.
>
> :   lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
>     ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
>
> Also, the indentation of the second line is preserved (once it is set) but
> it would be nice to have fill-paragraph automatically indent the second
> line by four spaces (in auto-fill-mode) if the first line begins with a
> colon.
>
> Any tips/advice/suggestions/pointers much appreciated.
>
> Sebastian

your question is more general than the fill-paragraph.

The essence of fill-paragraph is simple, it just insert a newline char
in every na count number of chars.

What you want to do is easy to write too. Here's the basic steps.
Suppose you are writing my-transform-region.

• check if the first few char is a colon followed by 3 spaces.
• if not, then just call fill-paragraph.
• if so, then move cursor to fill-column number of chars, insert a eol
char, then insert 3 spaces, then repeat the process.

once you have this, you can have a wrapper my-transform function, that
marks a region delimited by 2 eols, then feed it to my-transform-
region. (so that, you don't have to text selection to call it. It'll
just work on the current paragraph)

it'll take maybe 20 to 30 min to write it.

If you know perl, python, php etc but not elisp, you can easily write
it in those lang with a elisp wrapper. Here:

• Elisp Wrapper For Perl Scripts
  http://xahlee.org/emacs/elisp_perl_wrapper.html

if you want to do it in elisp... i can't think of a example code close
to what you want, but this might help:

• Emacs Lisp Idioms
  http://xahlee.org/emacs/elisp_idioms.html

• Suggestions on Emacs's Line-Cutting Commands
  http://xahlee.org/emacs/modernization_fill-paragraph.html

  Xah
∑ http://xahlee.org/

       reply	other threads:[~2009-02-10 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.283.1234252813.31690.help-gnu-emacs@gnu.org>
2009-02-10 14:10 ` Xah Lee [this message]
2009-02-14  2:32   ` Customising fill-paragrah Iain Dalton
2009-02-11 21:44 ` Chetan
2009-02-10  8:02 Sebastian Tennant

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=0012f3e9-3378-4714-9c82-14d2a7e3837f@z27g2000prd.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.