Sławomir Grochowski <[email protected]> writes: > The resulting buffer is currently: > > Intro > #+COLUMNS: %TODO > * H > > rather than: > > #+COLUMNS: %TODO > Intro > * H
The latter indeed makes more sense. Maybe even in top-level property drawer. > This behavior follows directly from this part of > `org-columns-store-format': > > (goto-char (point-min)) > (unless (org-at-heading-p) (outline-next-heading)) > (let ((inhibit-read-only t)) > (insert-before-markers "#+COLUMNS: " fmt "\n")) > > A minimal behavior change would be to remove the call to > `outline-next-heading' and insert the keyword at the beginning of the > buffer instead: > > (goto-char (point-min)) > (let ((inhibit-read-only t)) > (insert-before-markers "#+COLUMNS: " fmt "\n")) That won't work if the Org buffer starts with top-level property drawer or, say, a comment. > Another possible policy would be to insert it after an initial block of > file-level keywords, i.e. after consecutive keyword lines near > `point-min' before the first non-keyword, non-blank line: > > #+TITLE: Notes > #+AUTHOR: Me > #+COLUMNS: %TODO Sticking to that block (if it exists) will make sense, yes. > This would keep COLUMNS with other file-level settings without moving it > past ordinary introductory text. It is a bit more complex than simply > inserting at `point-min', though, and I am not aware of an existing Org > helper that implements exactly this insertion policy. We actually need this kind of helper for #+TAGS, which currently have a bug when attempting to run org-set-tags-command before first heading. > My current refactoring keeps the existing behavior unchanged and adds a > test for it. Before relying on that test, I would like to confirm whether > the current insertion point is intentional and should be preserved, or > whether new #+COLUMNS keywords should instead be inserted at the > beginning of the buffer, or after an initial file keyword block. I do not see anything in the git logs and in the list history that says that current behavior is something other than arbitrary choice. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
