emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Prevent auto-fill-mode from filling Property values in drawers
@ 2018-01-30 16:50 Kaushal Modi
  2018-02-03 14:16 ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-01-30 16:50 UTC (permalink / raw)
  To: emacs-org list


[-- Attachment #1.1: Type: text/plain, Size: 1692 bytes --]

Hello,

I have noticed that auto-filling working on long (going past fill-column)
values in property drawers.

Here's a MWE:

=====
#+TITLE: Test case showing auto-filling happening in Property drawers too
* Heading
:PROPERTIES:
:DESCRIPTION: This is a very long description that will auto fill at the
=fill-column=. But this is inside a property drawer, so the auto-filling
should be disabled.
:END:
* COMMENT Local Variables
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# End:
=====

The value of that DESCRIPTION property is in a single line (I believe some
email clients auto-fill the text). Basically this is what it should look
like in emacs -Q after M-x toggle-truncate-lines:

[image: image.png]

Now if you hit return at the end of that long description, auto-fill kicks
in and turns that into this invalid drawer:

=====
#+TITLE: Test case showing auto-filling happening in Property drawers too
* Heading
:PROPERTIES:
:DESCRIPTION: This is a very long description that will auto fill at
the =fill-column=. But this is inside a property drawer, so the
auto-filling should be disabled.

:END:
* COMMENT Local Variables
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# End:
=====

This looks like a bug. Can the auto-filling be disabled in property drawers?

I can recreate this issue on both:
- Org stable (9.1.6 that's on emacs-26 branch) :: Org version: Org mode
version 9.1.6 (release_9.1.6-50-g96b33f @
/home/kmodi/usr_local/apps/6/emacs/emacs-26/share/emacs/26.0.91/lisp/org/)
- Org master ::Org mode version 9.1.6 (release_9.1.6-395-g8ecc4c @
/home/kmodi/usr_local/apps/6/emacs/emacs-26/share/emacs/site-lisp/org/)

Thanks.
-- 

Kaushal Modi

[-- Attachment #1.2: Type: text/html, Size: 2144 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 29850 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-01-30 16:50 Prevent auto-fill-mode from filling Property values in drawers Kaushal Modi
@ 2018-02-03 14:16 ` Kaushal Modi
  2018-02-03 14:29   ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-03 14:16 UTC (permalink / raw)
  To: emacs-org list


[-- Attachment #1.1: Type: text/plain, Size: 2039 bytes --]

Hello,

I am bumping this thread, as it very likely could have been missed.

If fixing that was already on the radar, sorry for the bump.

On Tue, Jan 30, 2018, 11:50 AM Kaushal Modi <kaushal.modi@gmail.com> wrote:

> Hello,
>
> I have noticed that auto-filling working on long (going past fill-column)
> values in property drawers.
>
> Here's a MWE:
>
> =====
> #+TITLE: Test case showing auto-filling happening in Property drawers too
> * Heading
> :PROPERTIES:
> :DESCRIPTION: This is a very long description that will auto fill at the
> =fill-column=. But this is inside a property drawer, so the auto-filling
> should be disabled.
> :END:
> * COMMENT Local Variables
> # Local Variables:
> # fill-column: 70
> # eval: (auto-fill-mode 1)
> # End:
> =====
>
> The value of that DESCRIPTION property is in a single line (I believe some
> email clients auto-fill the text). Basically this is what it should look
> like in emacs -Q after M-x toggle-truncate-lines:
>
> [image: image.png]
>
> Now if you hit return at the end of that long description, auto-fill kicks
> in and turns that into this invalid drawer:
>
> =====
> #+TITLE: Test case showing auto-filling happening in Property drawers too
> * Heading
> :PROPERTIES:
> :DESCRIPTION: This is a very long description that will auto fill at
> the =fill-column=. But this is inside a property drawer, so the
> auto-filling should be disabled.
>
> :END:
> * COMMENT Local Variables
> # Local Variables:
> # fill-column: 70
> # eval: (auto-fill-mode 1)
> # End:
> =====
>
> This looks like a bug. Can the auto-filling be disabled in property
> drawers?
>
> I can recreate this issue on both:
> - Org stable (9.1.6 that's on emacs-26 branch) :: Org version: Org mode
> version 9.1.6 (release_9.1.6-50-g96b33f @
> /home/kmodi/usr_local/apps/6/emacs/emacs-26/share/emacs/26.0.91/lisp/org/)
> - Org master ::Org mode version 9.1.6 (release_9.1.6-395-g8ecc4c @
> /home/kmodi/usr_local/apps/6/emacs/emacs-26/share/emacs/site-lisp/org/)
>
> Thanks.
> --
>
> Kaushal Modi
>


-- 

Kaushal Modi

[-- Attachment #1.2: Type: text/html, Size: 2844 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 29850 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:16 ` Kaushal Modi
@ 2018-02-03 14:29   ` Nicolas Goaziou
  2018-02-03 14:33     ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-03 14:29 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Hello,
>
> I am bumping this thread, as it very likely could have been missed.
>
> If fixing that was already on the radar, sorry for the bump.
>
> On Tue, Jan 30, 2018, 11:50 AM Kaushal Modi <kaushal.modi@gmail.com> wrote:
>
>> Hello,
>>
>> I have noticed that auto-filling working on long (going past fill-column)
>> values in property drawers.
>>
>> Here's a MWE:
>>
>> =====
>> #+TITLE: Test case showing auto-filling happening in Property drawers too
>> * Heading
>> :PROPERTIES:
>> :DESCRIPTION: This is a very long description that will auto fill at the
>> =fill-column=. But this is inside a property drawer, so the auto-filling
>> should be disabled.
>> :END:
>> * COMMENT Local Variables
>> # Local Variables:
>> # fill-column: 70
>> # eval: (auto-fill-mode 1)
>> # End:
>> =====
>>
>> The value of that DESCRIPTION property is in a single line (I believe some
>> email clients auto-fill the text). Basically this is what it should look
>> like in emacs -Q after M-x toggle-truncate-lines:
>>
>> [image: image.png]
>>
>> Now if you hit return at the end of that long description, auto-fill kicks
>> in and turns that into this invalid drawer:
>>
>> =====
>> #+TITLE: Test case showing auto-filling happening in Property drawers too
>> * Heading
>> :PROPERTIES:
>> :DESCRIPTION: This is a very long description that will auto fill at
>> the =fill-column=. But this is inside a property drawer, so the
>> auto-filling should be disabled.
>>
>> :END:
>> * COMMENT Local Variables
>> # Local Variables:
>> # fill-column: 70
>> # eval: (auto-fill-mode 1)
>> # End:
>> =====
>>
>> This looks like a bug. Can the auto-filling be disabled in property
>> drawers?

It is already the case. See `org-adaptive-fill-function': it returns nil
when at a node property.

I cannot reproduce your ECM.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:29   ` Nicolas Goaziou
@ 2018-02-03 14:33     ` Kaushal Modi
  2018-02-03 14:40       ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-03 14:33 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

On Sat, Feb 3, 2018, 9:29 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> It is already the case. See `org-adaptive-fill-function': it returns nil
> when at a node property.
>

I thought so too, because the filling doesn't happen on M-q. So it took me
a while to come with that complete ECM.

I cannot reproduce your ECM.
>

Did you copy and paste the whole ECM including the Local Variables? ..
because I can reproduce that in emacs -Q (emacs-26 branch).

It's something about auto-fill-mode being on, that's different from M-q.

>

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1296 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:33     ` Kaushal Modi
@ 2018-02-03 14:40       ` Nicolas Goaziou
  2018-02-03 14:55         ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-03 14:40 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Did you copy and paste the whole ECM including the Local Variables? ..
> because I can reproduce that in emacs -Q (emacs-26 branch).
>
> It's something about auto-fill-mode being on, that's different from
> M-q.

I think I spotted your mistake. Considering (a part of) your ECM:

   * Heading

   :PROPERTIES:
   :DESCRIPTION: This is a very long description that will auto fill at the
   =fill-column=. But this is inside a property drawer, so the auto-filling
   should be disabled.
   :END:

There's a line between the heading and the properties drawer, so it is
a regular drawer, where filling is allowed. `org-lint' warns you about
this.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:40       ` Nicolas Goaziou
@ 2018-02-03 14:55         ` Kaushal Modi
  2018-02-03 16:16           ` Nicolas Goaziou
  2018-02-03 16:20           ` Nick Dokos
  0 siblings, 2 replies; 22+ messages in thread
From: Kaushal Modi @ 2018-02-03 14:55 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

On Sat, Feb 3, 2018, 9:40 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Kaushal Modi <kaushal.modi@gmail.com> writes:
>
> I think I spotted your mistake. Considering (a part of) your ECM:
>
>    * Heading
>
>    :PROPERTIES:
>
>
> There's a line between the heading and the properties drawer, so it is
> a regular drawer,
>

I don't follow. I don't have that extra line.. I wonder why it shows up
like that to you.

You can see in this screenshot I pasted earlier that I have no empty line
between headline and property drawer:
http://lists.gnu.org/r/emacs-orgmode/2018-02/png5WGaeZ0gLm.png

I don't see that empty line on the web too:
http://lists.gnu.org/r/emacs-orgmode/2018-01/msg00497.html

>

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1559 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:55         ` Kaushal Modi
@ 2018-02-03 16:16           ` Nicolas Goaziou
  2018-02-03 16:20           ` Nick Dokos
  1 sibling, 0 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-03 16:16 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> On Sat, Feb 3, 2018, 9:40 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
>> Kaushal Modi <kaushal.modi@gmail.com> writes:
>>
>> I think I spotted your mistake. Considering (a part of) your ECM:
>>
>>    * Heading
>>
>>    :PROPERTIES:
>>
>>
>> There's a line between the heading and the properties drawer, so it is
>> a regular drawer,
>>
>
> I don't follow. I don't have that extra line.. I wonder why it shows up
> like that to you.
>
> You can see in this screenshot I pasted earlier that I have no empty line
> between headline and property drawer:
> http://lists.gnu.org/r/emacs-orgmode/2018-02/png5WGaeZ0gLm.png
>
> I don't see that empty line on the web too:
> http://lists.gnu.org/r/emacs-orgmode/2018-01/msg00497.html

It may be Gnus, then, because the message above appears with a blank
line below the heading.

Anyways, I cannot reproduce your issue, even with local variables.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 14:55         ` Kaushal Modi
  2018-02-03 16:16           ` Nicolas Goaziou
@ 2018-02-03 16:20           ` Nick Dokos
  2018-02-03 17:41             ` Kaushal Modi
  1 sibling, 1 reply; 22+ messages in thread
From: Nick Dokos @ 2018-02-03 16:20 UTC (permalink / raw)
  To: emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> On Sat, Feb 3, 2018, 9:40 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
>     Kaushal Modi <kaushal.modi@gmail.com> writes:
>    
>     I think I spotted your mistake. Considering (a part of) your ECM:
>    
>        * Heading
>    
>        :PROPERTIES:
>         
>    
>     There's a line between the heading and the properties drawer, so it is
>     a regular drawer, 
>
> I don't follow. I don't have that extra line.. I wonder why it shows up like that to you. 
>
> You can see in this screenshot I pasted earlier that I have no empty line between headline and property drawer: http://lists.gnu.org/r/emacs-orgmode/2018-02/png5WGaeZ0gLm.png
>
> I don't see that empty line on the web too: http://lists.gnu.org/r/emacs-orgmode/2018-01/msg00497.html
>

FWIW, I tried it too both with emacs -Q and in my normal working emacs: I cannot reproduce it.
-- 
Nick

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 16:20           ` Nick Dokos
@ 2018-02-03 17:41             ` Kaushal Modi
  2018-02-03 18:11               ` Nick Dokos
  2018-02-03 22:16               ` Nicolas Goaziou
  0 siblings, 2 replies; 22+ messages in thread
From: Kaushal Modi @ 2018-02-03 17:41 UTC (permalink / raw)
  To: Nick Dokos, Nicolas Goaziou; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1619 bytes --]

On Sat, Feb 3, 2018 at 11:22 AM Nick Dokos <ndokos@gmail.com> wrote:

>
> FWIW, I tried it too both with emacs -Q and in my normal working emacs: I
> cannot reproduce it.
>

Hello Nick, Nicolas,

Thank you for trying out the MWE. I don't know what we could be doing
differently.

So here's a recorded screencast ( https://i.imgur.com/8u8KhAy.gifv ) to get
rid of any miscommunication.

Please follow this exact steps (just to reiterate, I am relying on
auto-fill-mode to not trigger when RET is pressed.. I am not using M-q
anywhere):

1. Download the attached Org file (property-auto-fill.org).
2. emacs -Q property-auto-fill.org
3. Navigate to the Heading, hit TAB, then to the PROPERTY drawer, hit TAB.
4. Go to the end of the DESCRIPTION property, hit RET.
5. Doesn't that property auto-fill for you? As you see in the screencast,
the auto-filling happens for me.

Here's the C-h l log as you see in the linked screencast:

 C-n [next-line]
 C-n [next-line]
 C-a [org-beginning-of-line]
 C-p [previous-line]
 C-a [org-beginning-of-line]
 <tab> [org-cycle]
 C-n [next-line]
 <tab> [org-cycle]
 C-n [next-line]
 C-e [org-end-of-line]
 <return> [org-return]
 C-h l [view-lossage]

And finally the emacs and Org versions in that emacs -Q session:

- GNU Emacs 26.0.91 (build 4, x86_64-pc-linux-gnu, GTK+ Version 2.24.23) of
2018-01-31 built using repository revision
http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-26&id=56c37bbdb60f201791b57a3af2f47b7517de810c
- Org mode version 9.1.6 (release_9.1.6-50-g96b33f @
/home/kmodi/usr_local/apps/6/emacs/emacs-26/share/emacs/26.0.91/lisp/org/)
-- 

Kaushal Modi

[-- Attachment #1.2: Type: text/html, Size: 2488 bytes --]

[-- Attachment #2: property-auto-fill.org --]
[-- Type: application/octet-stream, Size: 366 bytes --]

#+TITLE: Test case showing auto-filling happening in Property drawers too
* Heading
:PROPERTIES:
:DESCRIPTION: This is a very long description that will auto fill at the =fill-column=. But this is inside a property drawer, so the auto-filling should be disabled.
:END:
* COMMENT Local Variables
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# End:

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 17:41             ` Kaushal Modi
@ 2018-02-03 18:11               ` Nick Dokos
  2018-02-03 22:16               ` Nicolas Goaziou
  1 sibling, 0 replies; 22+ messages in thread
From: Nick Dokos @ 2018-02-03 18:11 UTC (permalink / raw)
  To: emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> On Sat, Feb 3, 2018 at 11:22 AM Nick Dokos <ndokos@gmail.com> wrote:
>
>     FWIW, I tried it too both with emacs -Q and in my normal working emacs: I cannot reproduce it.
>
> Hello Nick, Nicolas,
>
> Thank you for trying out the MWE. I don't know what we could be doing differently.
>
> So here's a recorded screencast ( https://i.imgur.com/8u8KhAy.gifv ) to get rid of any miscommunication.
>

Sorry, I was wrong: I'm not sure why I could not reproduce it earlier, but I just retried it
both with -Q (9.1.6 -50) and my working org-mode (9.1.6 -392) and I do get auto-filled in both
versions. Sometimes I think I'm going mad...

-- 
Nick

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 17:41             ` Kaushal Modi
  2018-02-03 18:11               ` Nick Dokos
@ 2018-02-03 22:16               ` Nicolas Goaziou
  2018-02-04 15:52                 ` Kaushal Modi
  1 sibling, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-03 22:16 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Nick Dokos, emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> 1. Download the attached Org file (property-auto-fill.org).
> 2. emacs -Q property-auto-fill.org
> 3. Navigate to the Heading, hit TAB, then to the PROPERTY drawer, hit TAB.
> 4. Go to the end of the DESCRIPTION property, hit RET.

Wait... What?

Properties drawers do not contain blank lines. If you hit <RET>, this is
no longer a properties drawer, but a regular one, where auto-filling is
allowed.

If you want to add a new property, use C-c C-x p, or, if you insist on
typing it manually, use C-q <RET> instead.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-03 22:16               ` Nicolas Goaziou
@ 2018-02-04 15:52                 ` Kaushal Modi
  2018-02-04 22:16                   ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-04 15:52 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

On Sat, Feb 3, 2018 at 5:16 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
> Wait... What?
>

Yes :) I had thought I couldn't get my point across correctly the first
time.


> Properties drawers do not contain blank lines. If you hit <RET>, this is
> no longer a properties drawer, but a regular one, where auto-filling is
> allowed.
>

Of course. But "the right thing" would be to prevent call to auto filling
within `org-return` (somehow? I haven't yet dug deeper into that) if point
is in a property drawer.

If you want to add a new property, use C-c C-x p, or, if you insist on
> typing it manually, use C-q <RET> instead.
>

C-c C-x p is a bit unnatural and also longer to type than RET, especially
if the point is already inside the property drawer. Yes, if my point is
inside the subtree, and I think of adding a property, C-c C-x p is great!

C-q  RET is a good tip, but again, RET would be better.

I'll try hacking something around this, tweaking org-return should work
using a simple advice. Would a patch be welcome for this?
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1812 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-04 15:52                 ` Kaushal Modi
@ 2018-02-04 22:16                   ` Nicolas Goaziou
  2018-02-05 21:59                     ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-04 22:16 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Nick Dokos, emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Of course. But "the right thing" would be to prevent call to auto filling
> within `org-return` (somehow? I haven't yet dug deeper into that) if point
> is in a property drawer.

`org-return' doesn't call any auto fill function.

> If you want to add a new property, use C-c C-x p, or, if you insist on
>> typing it manually, use C-q <RET> instead.
>>
>
> C-c C-x p is a bit unnatural and also longer to type than RET,

Yet, it doesn't break properties drawers.

> especially
> if the point is already inside the property drawer. Yes, if my point is
> inside the subtree, and I think of adding a property, C-c C-x p is great!
>
> C-q  RET is a good tip, but again, RET would be better.

Actually, that would be C-q C-j, not C-q <RET>

> I'll try hacking something around this, tweaking org-return should work
> using a simple advice. Would a patch be welcome for this?

I don't think tweaking `org-return' is a good solution. This is not the
only way to break a line (e.g. "C-q C-j", or "C-M-o"), so it would not
be a panacea.

You may want to use fill-nobreak-predicate variable instead, e.g. with
`org-at-property-p'.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-04 22:16                   ` Nicolas Goaziou
@ 2018-02-05 21:59                     ` Kaushal Modi
  2018-02-11 13:12                       ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-05 21:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2209 bytes --]

On Sun, Feb 4, 2018 at 5:16 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> `org-return' doesn't call any auto fill function.
>

It sort of does, indirectly, via (newline). Please see the proposed patch
at the end of this email.

Yet, it doesn't break properties drawers.
>

I agree. Though this patch fixes what <RET> shouldn't do when point is in
the property drawer.

If someone has:

=====
* Headline
:PROPERTY:
:FOO: some long line that goes beyond fill column
:END:
=====

It would be highly unlikely that some would want to save that file as
(assuming it got formatted as below because of auto filling):

=====
* Headline
:PROPERTY:
:FOO: some long line that goes beyond
fill column
:END:
=====

So the below patch prevents <RET> from doing the above


> I don't think tweaking `org-return' is a good solution. This is not the
> only way to break a line (e.g. "C-q C-j", or "C-M-o"), so it would not
> be a panacea.
>

I tried C-q C-j and C-M-o, and both don't allow the auto-filling to happen,
even without the below patch.


> You may want to use fill-nobreak-predicate variable instead, e.g. with
> `org-at-property-p'.
>

I gave that a try, by tweaking fill-nobreak-predicate inside the
org-setup-filling function. But that doesn't work. Looks like the predicate
is evaluated *after* `newline' inserts the newline.. and so
`org-at-property-p' would evaluate to nil.

** The patch **

Looking at the source code of `newline' defun, I came up with this and it
works!

diff --git a/lisp/org.el b/lisp/org.el
index 688e48bcc1d..9367304e900 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20471,7 +20471,10 @@ object (e.g., within a comment).  In these case,
you need to use
          (delete-and-extract-region (point) (line-end-position))))
     (newline-and-indent)
     (save-excursion (insert trailing-data))))
-     (t (if indent (newline-and-indent) (newline))))))
+     (t (let ((auto-fill-function (if (org-at-property-p)
+                                      nil
+                                    auto-fill-function)))
+          (if indent (newline-and-indent) (newline)))))))

 (defun org-return-indent ()
   "Goto next table row or insert a newline and indent.


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 3557 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-05 21:59                     ` Kaushal Modi
@ 2018-02-11 13:12                       ` Nicolas Goaziou
  2018-02-11 13:24                         ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-11 13:12 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Nick Dokos, emacs-orgmode

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> +     (t (let ((auto-fill-function (if (org-at-property-p)
> +                                      nil
> +                                    auto-fill-function)))

    (and (not (org-at-property-p)) 
         auto-fill-function)

Could you add a comment explaining why this is needed?

Also, could you add a proper commit message to the patch?

Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 13:12                       ` Nicolas Goaziou
@ 2018-02-11 13:24                         ` Kaushal Modi
  2018-02-11 15:54                           ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-11 13:24 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

Hi Nicolas,

On Sun, Feb 11, 2018, 8:12 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
>     (and (not (org-at-property-p))
>          auto-fill-function)
>

Thanks for the feedback.

What I emailed earlier was just a buffer diff.

I'll convert that to a proper commit with comments and commit message, and
commit.

    Btw this is safe enough to commit to maint?

Thanks.

>

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1070 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 13:24                         ` Kaushal Modi
@ 2018-02-11 15:54                           ` Nicolas Goaziou
  2018-02-11 20:13                             ` Kaushal Modi
  0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-11 15:54 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Nick Dokos, emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> I'll convert that to a proper commit with comments and commit message, and
> commit.

Great!

>     Btw this is safe enough to commit to maint?

I think so.

Would you mind adding a test to `test-org/auto-fill-function' for good
measure?

Thank you.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 15:54                           ` Nicolas Goaziou
@ 2018-02-11 20:13                             ` Kaushal Modi
  2018-02-11 20:22                               ` Nicolas Goaziou
  2018-02-11 20:23                               ` Kaushal Modi
  0 siblings, 2 replies; 22+ messages in thread
From: Kaushal Modi @ 2018-02-11 20:13 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3899 bytes --]

On Sun, Feb 11, 2018 at 10:54 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
> Would you mind adding a test to `test-org/auto-fill-function' for good
> measure?


I was actually adding a test for org-return as the commit doesn't modify
the org-auto-fill-function.

The test I added was this.. but doesn't work. Can you please help?

Interactively, the org-return change works as expected, but the test fails
with this:

Test test-org/return condition:
    (ert-test-failed
     ((should
       (equal "* Heading
:PROPERTIES:
:SOME_PROP:This is a very long property value that goes beyond the
fill-column. But this is inside a property drawer, so the auto-filling
should be disabled.

:END:"
              (org-test-with-temp-text "* Heading
:PROPERTIES:
:SOME_PROP:This is a very long property value that goes beyond the
fill-column. But this is inside a property drawer, so the auto-filling
should be disabled.<point>
:END:" ... ... ... ...)))
      :form
      (equal "* Heading
:PROPERTIES:
:SOME_PROP:This is a very long property value that goes beyond the
fill-column. But this is inside a property drawer, so the auto-filling
should be disabled.

:END:" "* Heading
:PROPERTIES:
:SOME_PROP:This
is a very
long
property
value that
goes
beyond the
fill-column. But
this is
inside a
property
drawer, so
the
auto-filling
should be
disabled.

:END:")
      :value nil :explanation
      (array-elt 38
                 (different-atoms
                  (32 "#x20" "? ")
                  (10 "#xa" "?
")))))
   FAILED  741/764  test-org/return

Here's the patch with test included:

From 416be7c4b7adddffc0c41bba2a070c8849e16d82 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Sun, 11 Feb 2018 14:37:10 -0500
Subject: [PATCH] Do not auto-fill when point is in Org property drawer

* lisp/org.el (org-return): Set auto-fill-function to nil when point
  is in an Org property drawer.
* testing/lisp/test-org.el (test-org/return): Add test.

<http://lists.gnu.org/r/emacs-orgmode/2018-02/msg00102.html>
---
 lisp/org.el              | 8 +++++++-
 testing/lisp/test-org.el | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index b45cc06187d..b9daba84e6a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21111,7 +21111,13 @@ object (e.g., within a comment).  In these case,
you need to use
          (delete-and-extract-region (point) (line-end-position))))
     (newline-and-indent)
     (save-excursion (insert trailing-data))))
-     (t (if indent (newline-and-indent) (newline))))))
+     (t
+      ;; Do not auto-fill when point is in an Org property drawer.
+      (let ((auto-fill-function (and (not (org-at-property-p))
+                     auto-fill-function)))
+    (if indent
+        (newline-and-indent)
+      (newline)))))))

 (defun org-return-indent ()
   "Goto next table row or insert a newline and indent.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 17e7a223c48..1792950bba6 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1190,6 +1190,14 @@
   (should
    (equal "| a |\n\n| b |"
       (org-test-with-temp-text "| a |<point>\n| b |"
+        (org-return)
+        (buffer-string))))
+  ;; Do not auto-fill on hitting <RET> inside a property drawer.
+  (should
+   (equal "* Heading\n:PROPERTIES:\n:SOME_PROP:This is a very long
property value that goes beyond the fill-column. But this is inside a
property drawer, so the auto-filling should be disabled.\n\n:END:"
+      (org-test-with-temp-text "* Heading\n:PROPERTIES:\n:SOME_PROP:This
is a very long property value that goes beyond the fill-column. But this is
inside a property drawer, so the auto-filling should be
disabled.<point>\n:END:"
+        (setq-local fill-column 10)
+        (auto-fill-mode 1)
         (org-return)
         (buffer-string)))))

-- 
2.15.0


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 5169 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 20:13                             ` Kaushal Modi
@ 2018-02-11 20:22                               ` Nicolas Goaziou
  2018-02-11 20:29                                 ` Kaushal Modi
  2018-02-11 20:23                               ` Kaushal Modi
  1 sibling, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-11 20:22 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Nick Dokos, emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> I was actually adding a test for org-return as the commit doesn't modify
> the org-auto-fill-function.

OK.

> Interactively, the org-return change works as expected, but the test fails
> with this:
>
> Test test-org/return condition:
>     (ert-test-failed
>      ((should
>        (equal "* Heading
> :PROPERTIES:
> :SOME_PROP:This is a very long property value that goes beyond the
           ^^^
> fill-column. But this is inside a property drawer, so the auto-filling
> should be disabled.
>
> :END:"
>               (org-test-with-temp-text "* Heading
> :PROPERTIES:
> :SOME_PROP:This is a very long property value that goes beyond the
           ^^^
Wild guess: missing spaces?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 20:13                             ` Kaushal Modi
  2018-02-11 20:22                               ` Nicolas Goaziou
@ 2018-02-11 20:23                               ` Kaushal Modi
  1 sibling, 0 replies; 22+ messages in thread
From: Kaushal Modi @ 2018-02-11 20:23 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 154 bytes --]

On Sun, Feb 11, 2018, 3:13 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:

Sorry, ignore that, figured out the mistake in my test.

>

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 664 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 20:22                               ` Nicolas Goaziou
@ 2018-02-11 20:29                                 ` Kaushal Modi
  2018-02-11 20:33                                   ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2018-02-11 20:29 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 340 bytes --]

On Sun, Feb 11, 2018 at 3:22 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
> > :SOME_PROP:This is a very long property value that goes beyond the
>            ^^^
> Wild guess: missing spaces?
>

Yes, that was it.

Committed in
https://code.orgmode.org/bzg/org-mode/commit/fe7619cd184847227e9c1085b4f3c13a553f007b
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 844 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Prevent auto-fill-mode from filling Property values in drawers
  2018-02-11 20:29                                 ` Kaushal Modi
@ 2018-02-11 20:33                                   ` Nicolas Goaziou
  0 siblings, 0 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2018-02-11 20:33 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-orgmode

Kaushal Modi <kaushal.modi@gmail.com> writes:

> On Sun, Feb 11, 2018 at 3:22 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
> wrote:
>
>>
>> > :SOME_PROP:This is a very long property value that goes beyond the
>>            ^^^
>> Wild guess: missing spaces?
>>
>
> Yes, that was it.
>
> Committed in
> https://code.orgmode.org/bzg/org-mode/commit/fe7619cd184847227e9c1085b4f3c13a553f007b

Thank you.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-02-11 20:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-30 16:50 Prevent auto-fill-mode from filling Property values in drawers Kaushal Modi
2018-02-03 14:16 ` Kaushal Modi
2018-02-03 14:29   ` Nicolas Goaziou
2018-02-03 14:33     ` Kaushal Modi
2018-02-03 14:40       ` Nicolas Goaziou
2018-02-03 14:55         ` Kaushal Modi
2018-02-03 16:16           ` Nicolas Goaziou
2018-02-03 16:20           ` Nick Dokos
2018-02-03 17:41             ` Kaushal Modi
2018-02-03 18:11               ` Nick Dokos
2018-02-03 22:16               ` Nicolas Goaziou
2018-02-04 15:52                 ` Kaushal Modi
2018-02-04 22:16                   ` Nicolas Goaziou
2018-02-05 21:59                     ` Kaushal Modi
2018-02-11 13:12                       ` Nicolas Goaziou
2018-02-11 13:24                         ` Kaushal Modi
2018-02-11 15:54                           ` Nicolas Goaziou
2018-02-11 20:13                             ` Kaushal Modi
2018-02-11 20:22                               ` Nicolas Goaziou
2018-02-11 20:29                                 ` Kaushal Modi
2018-02-11 20:33                                   ` Nicolas Goaziou
2018-02-11 20:23                               ` Kaushal Modi

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).