From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Customising fill-paragrah Date: Tue, 10 Feb 2009 06:10:03 -0800 (PST) Organization: http://groups.google.com Message-ID: <0012f3e9-3378-4714-9c82-14d2a7e3837f@z27g2000prd.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1234281300 30225 80.91.229.12 (10 Feb 2009 15:55:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2009 15:55:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 10 16:56:14 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LWuy2-0003PC-RY for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Feb 2009 16:56:11 +0100 Original-Received: from localhost ([127.0.0.1]:34922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWuwj-0004v1-CY for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Feb 2009 10:54:49 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!z27g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 61 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1234275004 23563 127.0.0.1 (10 Feb 2009 14:10:04 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 10 Feb 2009 14:10:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z27g2000prd.googlegroups.com; posting-host=24.6.175.142; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:166723 comp.emacs:97774 X-Mailman-Approved-At: Tue, 10 Feb 2009 10:47:54 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:62034 Archived-At: On Feb 10, 12:02 am, Sebastian Tennant 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) bu= t > 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. =E2=80=A2 check if the first few char is a colon followed by 3 spaces. =E2=80=A2 if not, then just call fill-paragraph. =E2=80=A2 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: =E2=80=A2 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: =E2=80=A2 Emacs Lisp Idioms http://xahlee.org/emacs/elisp_idioms.html =E2=80=A2 Suggestions on Emacs's Line-Cutting Commands http://xahlee.org/emacs/modernization_fill-paragraph.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84