emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Wales <samologist@gmail.com>
To: "Martin Yrjölä" <martin.yrjola@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: newlines and buffer corruption [was Re: [PATCH] org-capture: fix capture breaking next headline]
Date: Wed, 24 Oct 2018 16:53:21 -0700	[thread overview]
Message-ID: <CAJcAo8vVX6E=EmttT0En4yNE_NpDyZW=0-exzT-CMB7L+QfdWQ@mail.gmail.com> (raw)

whether it is an example of it i am not sure, but the case in the
org-capture thread is typical of a class of buffer corruption bugs
that is common in org.

if you have found similar corruption in your org files and wondered
why, this is probably the cause.  newlines that you didn't enter are
also related.

examples:

1 in capture i use hooks to fix whitespace.

2 in block editing, c-c ', you can get similar issues at the end of
the block.  [this example, however, might be a cultural influence of
the root cause and not a bug caused by the root cause.]

3 at one point long ago i reported a bug where sorting in a narrowed
region would corrupt the buffer.  this had gone unnoticed probably
because when you sort it is not obvious that the buffer was corrupted.

also there are similar things with org tree to indirect buffer.

===

when i looked into it a long time ago, the root cause was the design
of outline mode of which org was or is a derived mode.

at least one outline mode function acts as if an entry or subtree
starts before the first star and ends before -- yes, before -- the
final newline in the entry text contents.  frequent org coders
probably know this, but probably not everybody does.

people write workarounds to fix it, or they have no problem with it
and they code to it, or they aren't aware of it and don't account for
it.  for edge cases.  which they forget all about when the bug occurs.

then code gets called by other code, which means there are assumptions
sometimes broken, or workarounds that are necessary, and then there is
buffer corruption.

this touches on old debates.  it isn't just emacs.  look at crontab and wc.

i predict that more bugs [and user workarounds] will occur.

                 reply	other threads:[~2018-10-24 23:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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='CAJcAo8vVX6E=EmttT0En4yNE_NpDyZW=0-exzT-CMB7L+QfdWQ@mail.gmail.com' \
    --to=samologist@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=martin.yrjola@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

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