[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Please help me with filling in (enhanced) text mode.

From: Alan Mackenzie
Subject: Please help me with filling in (enhanced) text mode.
Date: Fri, 13 May 2005 21:24:10 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

What I want to do is to extend text mode so that I can write lists of
items labelled by parenthesised Roman numerals, like this:

(i) Each item begins with a parenthesized Roman numeral
  and its second and subsequent lines should be indented by
  two spaces;
(ii) I want commands like M-q `fill-paragraph', and C-j  
  `newline-and-indent' to do the right thing in such Roman
(iii) Outside of these list items, text-mode should work as
  it always has.

My first try went something like this:

(defvar roman (regexp-opt '("i" "ii" "iii" "iv" "v" "vi" "vii" "vii" "ix"
(defun enable-paren-lists ()
  (setq paragraph-start (concat p-roman "\\|" paragraph-start)
        paragraph-separate paragraph-start))
(add-hook 'text-mode-hook 'enable-paren-lists)

It didn't work.  After some edebuggery, I took out the setqing of
paragraph-separate, and it started sort-of-working, but I still have to
type in the two spaces by hand after the first line break.

How can I get these two spaces inserted automatically after the first
line break?

I have tried reading the fine manuals[*], but they have left me beaten.
They seem vague and circular:  For example, on Emacs's "Adaptive Fill"
page, there is talk about "taking the [fill] prefix from a line", but not
saying in detail how the taking is done.  Then we have 

   "   If the prefix found on the first line matches
   `adaptive-fill-first-line-regexp', or if it appears to be a
   comment-starting sequence (this depends on the major mode), then the
   prefix found is used for filling the paragraph, provided it would not
   act as a paragraph starter on subsequent lines."

, again not saying exactly how the "prefix found" is actually found.
Searching for information about `adaptive-fill-first-line-regexp', I go
for its doc-string:

   "*Regexp specifying whether to set fill prefix from a one-line
   paragraph.  When a paragraph has just one line, then after
   `adaptive-fill-regexp' finds the prefix at the beginning of the line,
   if it doesn't match this regexp, it is replaced with whitespace."

I'm having trouble parsing this:  To what do the two "it"s refer?  Which
of the two candidate regexps is "this" regexp (in the last line)?
"whether to set fill prefix":  the prefix for _which_ line or group of
lines?  How and when does `adaptive-fill-regexp' find a prefix?  That
symbol is a VARIABLE, not a function.  That implies some function uses it
to search with at some point.  Which?  I then go to further to
`adaptive-fill-regexp''s doc-string, and find this:

   *Regexp to match text at start of line that constitutes indentation.
   If Adaptive Fill mode is enabled, a prefix matching this pattern
   on the first and second lines of a paragraph is used as the
   standard indentation for the whole paragraph.

, at which point I'm wondering how text (apart from whitespace) can
constitute indentation.  Then I'm just getting my head around exactly
what a "prefix" is here, when my mental stack blows up in the complexity,
and I've lost track of what I was trying to do in the first place.

I've still not got the hang of what paragraph-start and
paragraph-separate mean.  Like, why are both variables set to the same
thing in text-mode?  What is the significance of a line which matches
both of these regexps?

Surely, setting things up for "simple" filling can't be that difficult?
Somebody please tell me I'm missing something blindingly obvious, and
what that thing is.


Thanks in advance!

[*] In the Emacs manual: pages "Fill Prefix", "Adaptive Fill";  In the
Elisp manual: Page "Filling". 

Alan Mackenzie (Munich, Germany)
Email: address@hidden; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

reply via email to

[Prev in Thread] Current Thread [Next in Thread]