From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?Q?Vincent_Bela=EFche?= Newsgroups: gmane.emacs.devel,gmane.emacs.orgmode Subject: RE: Alinea filling (hanlding of explicit line-breaks) Date: Sat, 12 Mar 2011 22:09:36 +0100 Message-ID: <801v2cnizz.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1299964212 22446 80.91.229.12 (12 Mar 2011 21:10:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Mar 2011 21:10:12 +0000 (UTC) Cc: Org mode , emacs-devel@gnu.org To: Stefan Monnier , Karl Berry Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 12 22:10:07 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PyW4Z-0008Jd-1K for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2011 22:10:03 +0100 Original-Received: from localhost ([127.0.0.1]:35840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyW4Y-0001SN-8v for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2011 16:10:02 -0500 Original-Received: from [140.186.70.92] (port=34593 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyW4O-0001Or-RH for emacs-devel@gnu.org; Sat, 12 Mar 2011 16:09:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyW4L-00077Y-3L for emacs-devel@gnu.org; Sat, 12 Mar 2011 16:09:52 -0500 Original-Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:28495 helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyW4K-00077E-M5 for emacs-devel@gnu.org; Sat, 12 Mar 2011 16:09:49 -0500 Original-Received: from CHOUNEK ([92.139.229.150]) by mwinf5d30 with ME id JM9k1g0083FLVPg03M9lAM; Sat, 12 Mar 2011 22:09:47 +0100 X-Antivirus: avast! (VPS 110312-0, 12/03/2011), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.12.242.129 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137166 gmane.emacs.orgmode:39297 Archived-At: 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. VBR, Vincent From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Vincent_Bela=EFche?= Subject: RE: Alinea filling (hanlding of explicit line-breaks) Date: Sat, 12 Mar 2011 22:09:36 +0100 Message-ID: <801v2cnizz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org To: Stefan Monnier , Karl Berry Cc: Org mode , emacs-devel@gnu.org List-Id: emacs-orgmode.gnu.org 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. VBR, Vincent