10

I love org-mode, but one of the things that has always bugged me is that, if the point is after a collapsed subtree's ellipsis, pressing TAB doesn't expand it. For example, if the point is here (represented by |):

* Grandiose Plans
** Save the world...|
** Colonize Mars...

...and I press TAB, nothing happens. Instead, I have to put the point here:

* Grandiose Plans
** Save the world|...
** Colonize Mars...

...and then I can expand the subtree.

Note that using C-e to move the cursor to the end of a heading doesn't fix this behavior, it just works around it. For example, look at this tree:

* Long level one heading foo bar baz fizz buzz|...
** Shorter level two heading...

The point is at the end of the first heading. If I press the down arrow or C-n to move down a line, the point will be here:

* Long level one heading foo bar baz fizz buzz...
** Shorter level two heading...|

...and pressing TAB will not expand the second-level heading.

The idea is to fix TAB so that it will expand the heading anyway. That way, instead of having to do C-n C-e TAB, one can just do C-n TAB.

I haven't been able to find out anything about fixing this behavior. Am I missing something, or does some code need to be written? Thanks.

3 Answers3

3

Try this:

(setq org-special-ctrl-a/e t)

Then C-e moves to before the ellipses, not after.

scbagley
  • 609
  • 3
  • 3
  • 1
    Thanks, but I already have that set, and it doesn't solve the problem. For example, if a first-level heading is 80-characters-long, and the second-level heading is 40-characters-long, and the point is at the end of the first-level heading, and I press the down arrow or `C-n`, the point will move to the second-level heading beyond the ellipsis. –  Sep 23 '15 at 16:53
  • 2
    @blujay Setting this option does make your examples work as desired for me. I've got emacs 24.5.1, org 8.3.1, on OS X 10.10.5, if that helps. Running `emacs -Q` and requiring org gets me version 8.2.10, which does reproduce your examples. – scbagley Sep 23 '15 at 22:18
  • Thank you! I am still on Org 8.2.4, the version packaged in my distro. I guess I should go ahead and upgrade manually. I couldn't find anything in the changelog that would seem to cause this behavior to change in 8.3, but I'll take your word for it! :) I'll report back after upgrading. –  Sep 24 '15 at 02:36
2

org-reveal

When you are to the right of the ellipses you might be (depending what the ellipses are hiding) in effect down in the hierarchy tree and not in the respective headline. In this situation you could type C-u C-c C-r and the headline will be revealed (but you will end up with the cursor at another location). Or you have to change your cursor position first, as you have shown in your question (I would prefer a C-a though).

Dieter.Wilhelm
  • 1,836
  • 14
  • 25
  • By "behind the colons", you meant "after the ellipsis", right? I know you mean that, but the use of word "behind" makes me interpret as "before the ellipsis" or "to the left of the ellipsis". – Kaushal Modi Sep 23 '15 at 00:36
  • @kaushalmodi thanks for spotting this stupidity, was rather late, when I wrote it and I updated now. – Dieter.Wilhelm Sep 23 '15 at 04:28
  • 1
    Thanks, but the idea is to avoid having to move the point or use another key sequence. `TAB` with the point after the ellipsis ought to go ahead and expand the subtree. –  Sep 23 '15 at 16:59
2

This can be solved by adding a hook to org-tab-first-hook which adds org-end-of-line. Every time TAB is used it jumps to last visible character of the org-line, but before the ellipsis, and then opens/closes the container as usual.

(add-hook 'org-tab-first-hook 'org-end-of-line)
David
  • 61
  • 6