Вопрос

Say I want to enter information in an Org file that could be displayed in a tree-like format. Can Org help me with this?

For example I want Org to display a hierarchy of entities as follows:

ROOT
├── foo
│   └── bar
├── baz
├── bax
├── src
│   ├── main
│   │   ├── java
│   │   │   └── something
│   │   └── fine
│   ├── yes
│   └── no

How can I enter this information in a way that Org understands it so that it can render the tree as above?

Это было полезно?

Решение

You might be interested by ditaa block for this:

#+name: tree
#+begin_src ditaa
  ROOT      
  |
  +--foo
  |  +----bar
  |  
  +--baz   
  +--bax   
  +--src   
  |  +--main
  |  |  +---java
  |  |  |   +---something
  |  |  |
  |  |  +---fine
  |  |
  |  +--yes
  |  +--no
#+end_src

typing C-c ` in the src block will put you in artist-mode, a mode made for editing ascii art and that should make editing those tree easier.

Другие советы

Assuming ROOT is a title that you would want displayed, you can do something like

* ROOT
** foo
*** bar

** baz

** bax

** src
*** main
**** java
***** something

**** fine

*** yes

*** no

The empty lines are optional. I just use them for readability.

If you only want to use one asterisk per level, checkout this link which explains how you can modify org-mode to use indentation and a single asterisk.

If the directory already exists you can use tree, as explained here. I've tried both and had issue with executing ditaa sometimes (emacs couln't find the ditaa.jar in some installations). Furthermore, ditaa output is an image, but the output of tree is text. You can use a src_block like this:

#+BEGIN_SRC sh :results output :exports results
tree /path/to/dir
#+END_SRC
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top