evil-org-mode icon indicating copy to clipboard operation
evil-org-mode copied to clipboard

o and O don't respect folded headings

Open e-matteson opened this issue 8 years ago • 3 comments

If I press o while on a folded heading, I would like to the new line to be added after body of the heading, not before. As an example, where | indicates cursor position, start with:

* |heading this is the body

Fold the heading:

* |heading...

Press o. Expected behavior:

* heading...

|

Observed behavior:

* heading

|...

Is the observed behavior what you intended? Is there some reason why that's better?

If not, I think it can be fixed by making clever-insert-item use evil-open-below instead of insert.

e-matteson avatar May 11 '16 23:05 e-matteson

I was playing around with this as well. Is it desirable to keep the body folded while adding to it? This also seems to get weird if there are subheadings.

* Heading
** Subheading
   If I press "o" with evil-open-below, I insert in the subheading.

sentientcucumber avatar Jun 05 '16 22:06 sentientcucumber

Hmm. I would prefer if a folded heading was treated exactly like a single, normal line. No automatic unfolding, no modifying any of the content inside the fold.

The way I use org, I often have a big, folded heading containing 100+ subheadings. I press o on the big heading so I can create another big heading below it at the same level. I don't want the 100+ subheadings to suddenly appear and clutter my screen, and I don't want to add or modify subheadings - if I did, I would have unfolded the big heading first. But other people might have different ideas about what's most intuitive and what fits best with their workflow. What do you think?

e-matteson avatar Jun 06 '16 17:06 e-matteson

That behavior sounds about right; I think I misread your original post.

I was playing around with this in my dotfiles. It's doesn't do exactly what the docstring says (doesn't create a newline if not on a heading or list). I have it bound to the insert state, but could easily be added to normal if desired.

(defun shellhead/smart-org-insert ()
  "Creates a new heading if currently in a heading, creates a new list item 
   if in a list, or creates a newline if neither."
  (interactive)
  (cond
   ((org-at-heading-p) (org-insert-heading-respect-content))
   ((org-at-item-p) (org-insert-item))))

(evil-define-key 'insert org-mode-map
  (kbd "C-o") 'shellhead/smart-org-insert)

sentientcucumber avatar Jun 06 '16 23:06 sentientcucumber