emacs-orgmode
[Top][All Lists]
Advanced

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

[O] RE: Alinea filling (hanlding of explicit line-breaks)


From: Vincent Belaïche
Subject: [O] RE: Alinea filling (hanlding of explicit line-breaks)
Date: Sat, 12 Mar 2011 22:09:36 +0100

Karl: I put you in the loop for info, because in Texinfo mode I think
that @* is used as an alinea separator similar to \\ in Org mode.

> From: address@hidden
> To: address@hidden
> Date: Wed, 16 Feb 2011 10:02:37 -0500
> CC: address@hidden; address@hidden
> Subject: Re: Alinea filling (hanlding of explicit line-breaks)
>
> >> An important question here is: is it important for M-} to ignore those \\?
> > I guess so, this is the current default Org behaviour anyhow.
>
> Good.
>
> > as far as I understand, it would be anyhow possible to move point on
> > an alinea-by-alinea basis just by configuring the tailing \\ as
> > anohter paragraph separator.
>
> Actually, no, because paragraph-separate would cause the whole line
> that ends with \\ to be treated as not being part of a paragraph, and
> paragraph-start wouldn't be appropriate either.  Hence the "good"
> above :-(
>
> >> Of course fill-paragraph-function sucks because it only applies to
> >> fill-paragraph and not to fill-region.
>
> > Do you mean that `fill-paragraph-function' is some kind of obsolete
> > feature and that people should use another kind of hook, and if so
> > which one?
>
> Yes and no: there is no replacement for it. There is
> fill-forward-paragraph-function, which can handle some of the cases
> for which fill-paragraph-function has been used, but there would need
> to be something like a fill-region-as-paragraph-function and we don't
> have that yet :-(
>
>
> Stefan
>
Hello Stefan & al,

I have implemented the thing locally on my machine. It works well but
there is still something missing: the line containing the `\\' alinea
separtor is not filled. 

Here is what I did:

+ In org-set-autofill-regexps function I added
    (org-set-local 'fill-forward-paragraph-function 'org-fill-foward-paragraph)

+ I created the following function:

  (defun org-fill-foward-paragraph (&optional arg)
    (let ((paragraph-separate (concat ".*\\\\$\\|" paragraph-separate )))
      (forward-paragraph arg)    ))

Note that I my 7.01h version of org --- which is older than the latest
one --- org-fill-paragraph is roughly like this:

(defun org-fill-paragraph (&optional justify)
  "Re-align a table, pass through to fill-paragraph if no table."
  (let ((table-p (org-at-table-p))
        (table.el-p (org-at-table.el-p)))
    (cond ((and (equal (char-after (point-at-bol)) ?*)
                (save-excursion (goto-char (point-at-bol))
                                (looking-at outline-regexp)))
           t)                                        ; skip headlines
          (table.el-p t)                             ; skip table.el tables
          (table-p (org-table-align) t)              ; align org-mode tables
          (t nil); let fill.el do the job
)))

That is to say there is a case where org lets fill.el do the job, while
in a later version (e.g. 7.4) org does some "\\\\$" detection on its
own without the use of the fill-forward-paragraph-function.

So, after more thinking about it the problem is the following: the
fill-forward-paragraph has only one parameter which is the paragraph
number --- with n = 0 => current --- but for finding the paragraph
boundary we need *two* parameter

=> 1st argument: paragraph number
=> 2nd argument: whether we want to point at the beginning the paragraph or to 
the end
   of the paragraph. 

=> maybe paragraph-separate could be a list of 3 items (REGEXP BEG END)
   where REGEXP is the usual regexp matching the separator, and BEG and
   END when non nil are function to go the the beginning of next or to
   the end of previous assuming that the match data corresponds to a
   match of REGEXP. This way would be really the most flexible.


VBR,
   Vincent



reply via email to

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