emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* newline or no newline at end of capture: expected behavior
@ 2020-09-20  5:29 Samuel Wales
  2020-09-20  5:36 ` Samuel Wales
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-20  5:29 UTC (permalink / raw)
  To: emacs-orgmode

i want to check on what is /supposed/ to occur in 9.4 maint.

if i capture an entry that has a newline at the end of the last line
in the entry, is it supposed to end the entry with a blank line?  or
is it supposed to end the entry with the last line?  [i want last
line.]

if i capture an entry that does NOT have a newline at the end of the
last line in the entry, is it supposed to end the entry with the last
line?  [i want last line but i never do this deliberately.]

thank you.

-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-20  5:29 newline or no newline at end of capture: expected behavior Samuel Wales
@ 2020-09-20  5:36 ` Samuel Wales
  2020-09-23  7:24   ` Bastien
  2020-09-23 21:30   ` Samuel Wales
  0 siblings, 2 replies; 12+ messages in thread
From: Samuel Wales @ 2020-09-20  5:36 UTC (permalink / raw)
  To: emacs-orgmode

third question:

if you capture a completely blank capture buffer, is it supposed to
insert a blank line right after the target headline, or is it supposed
to be a no-op?  [i prefer no-op.]

fourth question:

if you capture a capture buffer with a newline, [same options].  [i
prefer no-op.]


this is the complete set of questions now.

basically i am getting unwanted newlines all over the place when i
capture.  but i want to confirm expected behavior for all 4 questions.

thank you.


On 9/19/20, Samuel Wales <samologist@gmail.com> wrote:
> i want to check on what is /supposed/ to occur in 9.4 maint.
>
> if i capture an entry that has a newline at the end of the last line
> in the entry, is it supposed to end the entry with a blank line?  or
> is it supposed to end the entry with the last line?  [i want last
> line.]
>
> if i capture an entry that does NOT have a newline at the end of the
> last line in the entry, is it supposed to end the entry with the last
> line?  [i want last line but i never do this deliberately.]
>
> thank you.
>
> --
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-20  5:36 ` Samuel Wales
@ 2020-09-23  7:24   ` Bastien
  2020-09-23 21:29     ` Samuel Wales
  2020-09-23 21:30   ` Samuel Wales
  1 sibling, 1 reply; 12+ messages in thread
From: Bastien @ 2020-09-23  7:24 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hi Samuel,

Samuel Wales <samologist@gmail.com> writes:

> basically i am getting unwanted newlines all over the place when i
> capture.  but i want to confirm expected behavior for all 4 questions.

Let's take this one by one.  

Can you provide the *worst* use case of Org going completely insane
regarding empty lines after captured notes?

-- 
 Bastien


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-23  7:24   ` Bastien
@ 2020-09-23 21:29     ` Samuel Wales
  0 siblings, 0 replies; 12+ messages in thread
From: Samuel Wales @ 2020-09-23 21:29 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

i have been trying various hooks so this might not be the worst case,
but i know that finalizing a completely empty buffer will insert a
newline after the target.  that can't be worked around with hooks.


On 9/23/20, Bastien <bzg@gnu.org> wrote:
> Hi Samuel,
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> basically i am getting unwanted newlines all over the place when i
>> capture.  but i want to confirm expected behavior for all 4 questions.
>
> Let's take this one by one.
>
> Can you provide the *worst* use case of Org going completely insane
> regarding empty lines after captured notes?
>
> --
>  Bastien
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-20  5:36 ` Samuel Wales
  2020-09-23  7:24   ` Bastien
@ 2020-09-23 21:30   ` Samuel Wales
  2020-09-27  4:13     ` Samuel Wales
  1 sibling, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-23 21:30 UTC (permalink / raw)
  To: emacs-orgmode

i have the same question for headline-only capture
buffers.  i.e. what is the expected result with and without trailing
newline.


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-23 21:30   ` Samuel Wales
@ 2020-09-27  4:13     ` Samuel Wales
  2020-09-27  7:16       ` Richard Lawrence
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-27  4:13 UTC (permalink / raw)
  To: emacs-orgmode

hi bastien,

another example is, whenever i capture a headline like "* test\n" and
finalize, it creates a blank line after the headline.

is it expected that users should remove the final newline in the
capture buffer, in a finalize hook, to prevent this?

it would heolp me figure out whether it is pebcak, expected, or a bug
if i know what is the expected result, and whether users are expected
to capture only capture buffers that do not have final newlines.  [bug
on empty buffer still exists.]

On 9/23/20, Samuel Wales <samologist@gmail.com> wrote:
> i have the same question for headline-only capture
> buffers.  i.e. what is the expected result with and without trailing
> newline.
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27  4:13     ` Samuel Wales
@ 2020-09-27  7:16       ` Richard Lawrence
  2020-09-27  7:42         ` Samuel Wales
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Lawrence @ 2020-09-27  7:16 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

Hi Samuel,

> On 9/23/20, Samuel Wales <samologist@gmail.com> wrote:
>> i have the same question for headline-only capture
>> buffers.  i.e. what is the expected result with and without trailing
>> newline.

Just to clarify: are you aware of the :empty-lines, :empty-lines-before
and :empty-lines-after keys that you can set in org-capture-templates?
Are your questions about the default values of these keys?

I just tried a simple setup in emacs -Q with Org 9.4, namely:

(setq org-capture-templates
      '(("s" "simple" entry (file+headline "~/org/notes.org" "Foo")
      "* %?" :empty-lines 1)))

and Org seems to correctly respect the value of these keys when they are
specified explicitly. That is, with :empty-lines 0, no newlines are
added; with :empty-lines 1, a blank line appears on each side of the
captured entry; with :empty-lines-after 1, a blank line appears after,
but not before, the new entry; and so on.

Can you use these keys to get the behavior you are looking for? Or is
your question about something else?

-- 
Best,
Richard


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27  7:16       ` Richard Lawrence
@ 2020-09-27  7:42         ` Samuel Wales
  2020-09-27 10:39           ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-27  7:42 UTC (permalink / raw)
  To: Richard Lawrence; +Cc: emacs-orgmode

hi richard,

thank you.  when i can, i will try explicitly setting all three to 0
to see if that prevents the unwanted newlines, in the buffer with
newline on last line, and empty buffer, cases.

the docstring says empty-lines defaults to 0, which is what i want.
it does not say what the default for after and before are.

it /sounds/ like capture is supposed to produce the desired number
[and position] of empty lines regardless of whether the buffer is
empty or there is or is not a trailing newline on the final line of
hte buffer.  is this more or less correct?


On 9/27/20, Richard Lawrence <wyley.r@gmail.com> wrote:
> Hi Samuel,
>
>> On 9/23/20, Samuel Wales <samologist@gmail.com> wrote:
>>> i have the same question for headline-only capture
>>> buffers.  i.e. what is the expected result with and without trailing
>>> newline.
>
> Just to clarify: are you aware of the :empty-lines, :empty-lines-before
> and :empty-lines-after keys that you can set in org-capture-templates?
> Are your questions about the default values of these keys?
>
> I just tried a simple setup in emacs -Q with Org 9.4, namely:
>
> (setq org-capture-templates
>       '(("s" "simple" entry (file+headline "~/org/notes.org" "Foo")
>       "* %?" :empty-lines 1)))
>
> and Org seems to correctly respect the value of these keys when they are
> specified explicitly. That is, with :empty-lines 0, no newlines are
> added; with :empty-lines 1, a blank line appears on each side of the
> captured entry; with :empty-lines-after 1, a blank line appears after,
> but not before, the new entry; and so on.
>
> Can you use these keys to get the behavior you are looking for? Or is
> your question about something else?
>
> --
> Best,
> Richard
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27  7:42         ` Samuel Wales
@ 2020-09-27 10:39           ` Nicolas Goaziou
  2020-09-27 21:07             ` Samuel Wales
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2020-09-27 10:39 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode, Richard Lawrence

Hello,

Samuel Wales <samologist@gmail.com> writes:

> thank you.  when i can, i will try explicitly setting all three to 0
> to see if that prevents the unwanted newlines, in the buffer with
> newline on last line, and empty buffer, cases.
>
> the docstring says empty-lines defaults to 0, which is what i want.
> it does not say what the default for after and before are.
>
> it /sounds/ like capture is supposed to produce the desired number
> [and position] of empty lines regardless of whether the buffer is
> empty or there is or is not a trailing newline on the final line of
> hte buffer.  is this more or less correct?

I didn't read the whole thread, but a final newline is mandatory in all
capture templates, independently on the number of desired blank lines.
If such final newline is not provided, the capture mechanism will add
one.

The only exception is about empty capture templates, which are left
as-is, i.e. a "final newline" is not added in that case.

I don't know if that answers your question, but HTH.

Regards,
-- 
Nicolas Goaziou


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27 10:39           ` Nicolas Goaziou
@ 2020-09-27 21:07             ` Samuel Wales
  2020-09-27 21:08               ` Samuel Wales
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-27 21:07 UTC (permalink / raw)
  To: Samuel Wales, Richard Lawrence, emacs-orgmode

hi nicolas,

thanks, that helps to know that org adds a newline.  this prevents the
failure mode of corrupted headers.

just to confirm, do you mean capture /templates/ [potentially
verifiable by org] vs. /finalized buffers/?

it sounds like you mean templates, because otherwise org just does
whatever is necessary to create desired lines?

the user can mess with the buffer, so might leave a trailing newline
or not.  might copy from a file that ensures trailing newline, or one
that does not, etc.

thus finalized buffers can contain anything.  or nothing.

at present, possibly due to my own errors, without the options
specified explicitly, i get blank lines below the header if i finalize
the buffer with a trailing newline, and blank lines below the target
header if i capture with an empty buffer.  in maint.


On 9/27/20, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> thank you.  when i can, i will try explicitly setting all three to 0
>> to see if that prevents the unwanted newlines, in the buffer with
>> newline on last line, and empty buffer, cases.
>>
>> the docstring says empty-lines defaults to 0, which is what i want.
>> it does not say what the default for after and before are.
>>
>> it /sounds/ like capture is supposed to produce the desired number
>> [and position] of empty lines regardless of whether the buffer is
>> empty or there is or is not a trailing newline on the final line of
>> hte buffer.  is this more or less correct?
>
> I didn't read the whole thread, but a final newline is mandatory in all
> capture templates, independently on the number of desired blank lines.
> If such final newline is not provided, the capture mechanism will add
> one.
>
> The only exception is about empty capture templates, which are left
> as-is, i.e. a "final newline" is not added in that case.
>
> I don't know if that answers your question, but HTH.
>
> Regards,
> --
> Nicolas Goaziou
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27 21:07             ` Samuel Wales
@ 2020-09-27 21:08               ` Samuel Wales
  2020-09-28  2:31                 ` Samuel Wales
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2020-09-27 21:08 UTC (permalink / raw)
  To: Samuel Wales, Richard Lawrence, emacs-orgmode

... but i want to know what is expected.  it sopunds like org is
intended to produce the desired result regardless.  so i will messa
aroud more with my settings.

i am limited in comput3er use so it might take a while for me to
produce anything liek an mwe.  but i will check a few things.

On 9/27/20, Samuel Wales <samologist@gmail.com> wrote:
> hi nicolas,
>
> thanks, that helps to know that org adds a newline.  this prevents the
> failure mode of corrupted headers.
>
> just to confirm, do you mean capture /templates/ [potentially
> verifiable by org] vs. /finalized buffers/?
>
> it sounds like you mean templates, because otherwise org just does
> whatever is necessary to create desired lines?
>
> the user can mess with the buffer, so might leave a trailing newline
> or not.  might copy from a file that ensures trailing newline, or one
> that does not, etc.
>
> thus finalized buffers can contain anything.  or nothing.
>
> at present, possibly due to my own errors, without the options
> specified explicitly, i get blank lines below the header if i finalize
> the buffer with a trailing newline, and blank lines below the target
> header if i capture with an empty buffer.  in maint.
>
>
> On 9/27/20, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>> Hello,
>>
>> Samuel Wales <samologist@gmail.com> writes:
>>
>>> thank you.  when i can, i will try explicitly setting all three to 0
>>> to see if that prevents the unwanted newlines, in the buffer with
>>> newline on last line, and empty buffer, cases.
>>>
>>> the docstring says empty-lines defaults to 0, which is what i want.
>>> it does not say what the default for after and before are.
>>>
>>> it /sounds/ like capture is supposed to produce the desired number
>>> [and position] of empty lines regardless of whether the buffer is
>>> empty or there is or is not a trailing newline on the final line of
>>> hte buffer.  is this more or less correct?
>>
>> I didn't read the whole thread, but a final newline is mandatory in all
>> capture templates, independently on the number of desired blank lines.
>> If such final newline is not provided, the capture mechanism will add
>> one.
>>
>> The only exception is about empty capture templates, which are left
>> as-is, i.e. a "final newline" is not added in that case.
>>
>> I don't know if that answers your question, but HTH.
>>
>> Regards,
>> --
>> Nicolas Goaziou
>>
>
>
> --
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: newline or no newline at end of capture: expected behavior
  2020-09-27 21:08               ` Samuel Wales
@ 2020-09-28  2:31                 ` Samuel Wales
  0 siblings, 0 replies; 12+ messages in thread
From: Samuel Wales @ 2020-09-28  2:31 UTC (permalink / raw)
  To: Samuel Wales, Richard Lawrence, emacs-orgmode

well, fwiw, i am still getting empty lines for capture buffers with a
final newline and empty capture buffers.  idk if htat helps by
iutself.  recent maint [new org version] emacs 25.

On 9/27/20, Samuel Wales <samologist@gmail.com> wrote:
> ... but i want to know what is expected.  it sopunds like org is
> intended to produce the desired result regardless.  so i will messa
> aroud more with my settings.
>
> i am limited in comput3er use so it might take a while for me to
> produce anything liek an mwe.  but i will check a few things.
>
> On 9/27/20, Samuel Wales <samologist@gmail.com> wrote:
>> hi nicolas,
>>
>> thanks, that helps to know that org adds a newline.  this prevents the
>> failure mode of corrupted headers.
>>
>> just to confirm, do you mean capture /templates/ [potentially
>> verifiable by org] vs. /finalized buffers/?
>>
>> it sounds like you mean templates, because otherwise org just does
>> whatever is necessary to create desired lines?
>>
>> the user can mess with the buffer, so might leave a trailing newline
>> or not.  might copy from a file that ensures trailing newline, or one
>> that does not, etc.
>>
>> thus finalized buffers can contain anything.  or nothing.
>>
>> at present, possibly due to my own errors, without the options
>> specified explicitly, i get blank lines below the header if i finalize
>> the buffer with a trailing newline, and blank lines below the target
>> header if i capture with an empty buffer.  in maint.
>>
>>
>> On 9/27/20, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>>> Hello,
>>>
>>> Samuel Wales <samologist@gmail.com> writes:
>>>
>>>> thank you.  when i can, i will try explicitly setting all three to 0
>>>> to see if that prevents the unwanted newlines, in the buffer with
>>>> newline on last line, and empty buffer, cases.
>>>>
>>>> the docstring says empty-lines defaults to 0, which is what i want.
>>>> it does not say what the default for after and before are.
>>>>
>>>> it /sounds/ like capture is supposed to produce the desired number
>>>> [and position] of empty lines regardless of whether the buffer is
>>>> empty or there is or is not a trailing newline on the final line of
>>>> hte buffer.  is this more or less correct?
>>>
>>> I didn't read the whole thread, but a final newline is mandatory in all
>>> capture templates, independently on the number of desired blank lines.
>>> If such final newline is not provided, the capture mechanism will add
>>> one.
>>>
>>> The only exception is about empty capture templates, which are left
>>> as-is, i.e. a "final newline" is not added in that case.
>>>
>>> I don't know if that answers your question, but HTH.
>>>
>>> Regards,
>>> --
>>> Nicolas Goaziou
>>>
>>
>>
>> --
>> The Kafka Pandemic
>>
>> Please learn what misopathy is.
>> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>>
>
>
> --
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

end of thread, other threads:[~2020-09-28  2:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-20  5:29 newline or no newline at end of capture: expected behavior Samuel Wales
2020-09-20  5:36 ` Samuel Wales
2020-09-23  7:24   ` Bastien
2020-09-23 21:29     ` Samuel Wales
2020-09-23 21:30   ` Samuel Wales
2020-09-27  4:13     ` Samuel Wales
2020-09-27  7:16       ` Richard Lawrence
2020-09-27  7:42         ` Samuel Wales
2020-09-27 10:39           ` Nicolas Goaziou
2020-09-27 21:07             ` Samuel Wales
2020-09-27 21:08               ` Samuel Wales
2020-09-28  2:31                 ` Samuel Wales

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