emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Vincent Belaïche" <vincent.b.1@hotmail.fr>
To: Stefan Monnier <monnier@iro.umontreal.ca>,
	Karl Berry <karl@freefriends.org>
Cc: Org mode <emacs-orgmode@gnu.org>, emacs-devel@gnu.org
Subject: RE: Alinea filling (hanlding of explicit line-breaks)
Date: Sat, 12 Mar 2011 22:09:36 +0100	[thread overview]
Message-ID: <801v2cnizz.fsf@gmail.com> (raw)

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: monnier@iro.umontreal.ca
> To: vincent.b.1@hotmail.fr
> Date: Wed, 16 Feb 2011 10:02:37 -0500
> CC: emacs-orgmode@gnu.org; emacs-devel@gnu.org
> 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.


             reply	other threads:[~2011-03-12 21:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-12 21:09 Vincent Belaïche [this message]
2011-03-13  3:59 ` Alinea filling (hanlding of explicit line-breaks) Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2011-03-13 15:48 Alinea filling (hanlding of explicit line-breaks)‏ Vincent Belaïche
2011-03-13 21:34 ` Stefan Monnier
2011-03-13 13:49 Alinea filling (hanlding of explicit line-breaks) Vincent Belaïche
2011-02-16  6:42 Vincent Belaïche
2011-02-16 15:02 ` Stefan Monnier
2011-02-14 21:30 Vincent Belaïche
2011-02-15 17:22 ` Stefan Monnier
2011-02-13  8:47 Vincent Belaïche
2011-02-14 18:16 ` Stefan Monnier

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:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=801v2cnizz.fsf@gmail.com \
    --to=vincent.b.1@hotmail.fr \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=karl@freefriends.org \
    --cc=monnier@iro.umontreal.ca \


* 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 public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).