emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* newlines and buffer corruption [was Re: [PATCH] org-capture: fix capture breaking next headline]
@ 2018-10-24 23:53 Samuel Wales
  0 siblings, 0 replies; only message in thread
From: Samuel Wales @ 2018-10-24 23:53 UTC (permalink / raw)
  To: Martin Yrjölä; +Cc: Org Mode

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-24 23:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 23:53 newlines and buffer corruption [was Re: [PATCH] org-capture: fix capture breaking next headline] 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).