2

I am trying to set up a 2-pane writing setup in org-mode (similar to this). I'm using org-tree-to-indirect-buffer, and want to have the following functionality: 1. Opening a specific heading in a 2nd pane: Keeping the cursor is on a heading/ sub-heading and pressing a custom key should open a 2nd pane on the right with just that heading/ subheading in this new (editable) buffer.

For now, I'm able to do this using the following:

(defun org-tree-open-in-right-frame ()
    (interactive)
    (org-tree-to-indirect-buffer)
    (windmove-right))
    (add-hook 'org-mode-hook
    (lambda ()
    (define-key evil-normal-state-local-map [S-return] (quote org-tree-open-in-right-frame))

    (define-key evil-normal-state-local-map [return] (quote org-tree-to-indirect-buffer))

(I've taken this function from the VimValley setup linked above.)

  1. Switch back and forth between the main document and the 2nd pane using keyboard shortcuts. (Done using C-x o, or custom shortcut in evil-mode.)

  2. (This is where I'm stuck) Once in the main document (on the left) and at a different heading/subheading, pressing the same key as in #1 should open this new heading in the 2nd pane (and get rid of what was originally on the second pane). Again, this 2nd pane should be editable.

  3. While I'm editing the buffer on the 2nd pane, headings on the main document (on the 1st pane on the left) should stay collapsed.

Problem: Once I have a 2-pane setup, and am in the main document, pressing the assigned key in Step 1 opens a 3rd pane with the new heading/subheading, but the 2nd pane continues to show in the frame.

Additional dream setup: The 2nd pane should always open in olivetti-mode with a specific window size and font size (that is, the window with the main document (on the left) to occupy about a 25% - 30% of the frame).

enter image description here

For now, I am opening the 2nd pane as mentioned above, manually resizing the window, starting olivetti-mode for this second pane and increasing the font size. When done editing that section of the document, I close that window before starting a new 2nd pane for a different heading, resizing, starting, olivetti-mode, increasing font size... rinse and repeat. It works for now, but does not seem like an elegant solution.

(I'm not a programmer, and have no experience with elisp; most of my setup is cobbled using code snippets from configs shared by other helpful emacs users. I use org-mode primarily for writing prose and use vim's bindings using evil-mode.)

Other options: outline-toc comes close to what I'm trying to do. The package shackle looks like it can do what I'm trying here, but I'm not sure how. On another forum, I was told to try display-buffer-alist, but again, I'm unable to figure out how to use it.

I've tried to follow some ideas from the following sources, but haven't been able to make it work.

How can I get an org-mode outline in a 2nd buffer as a dynamic table of contents?

https://www.gnu.org/software/emacs/manual/html_node/emacs/Indirect-Buffers.html

https://www.gnu.org/software/emacs/manual/html_node/emacs/Outline-Views.html#Outline-Views

https://stackoverflow.com/questions/17156595/in-emacs-org-mode-how-to-narrow-display-to-two-subtrees-in-two-separate-files

1

A code snippet by @blujay posted here got me through. I made a few minor edits to narrow the org file to specific heading (posted here).

0

Maybe check out this solution: Dynamic TOC with an org subtree /element on a new window The code there may give you some inspiration.

  • Yes, that code snippet by @blujay worked. As I mentioned in the post you (@éric) linked to, the I just needed to 'widen' the org document before using org-narrow-to-element. Took me quite a while to figure this out, but I blame my complete lack of experience with elisp (or any intermediate level of programming) :). But finding that post was felt like this xkcd gem xkcd.com/979 – nb3pt470 Jan 19 at 16:02
0

There's now org-sidebar and org-sidebar-tree.

https://www.reddit.com/r/orgmode/comments/dbsngi/finally_solving_the_lack_of_a_treeview_navigation/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.