Skip to content

Commit 70b8f4c

Browse files
committed
Initial commit
0 parents  commit 70b8f4c

File tree

4 files changed

+4026
-0
lines changed

4 files changed

+4026
-0
lines changed

Cask

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(source melpa)
2+
3+
(package-file "org-fs-tree.el")
4+
5+
(development
6+
(depends-on "f")
7+
(depends-on "names"))

README.org

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#+title: org-fs-tree
2+
3+
* Why?
4+
5+
I created it because I wanted to make notes under various file names
6+
as I walked through the source dirs of a project I was to contribute
7+
to at work.
8+
9+
Soon, I found creating headings manually painful especially when
10+
similar file names occur in multiple subdirectories.
11+
12+
My first reaction was to use the following snippet to generate a org
13+
skeleton.
14+
15+
#+begin_src
16+
$ cd /base/of/src/dir
17+
$ find . -type f | sed 's/^/* /'
18+
#+end_src
19+
20+
which in turn generated a new top-level heading for file in the
21+
tree. This turned out to be very cumbersome as well since there was no
22+
way to fold subtrees which I wasn't interested in looking at immediately
23+
24+
Half-way creating new headings from common directory names and moving
25+
files to second-level headings etc. I noticed that I had lost a way to
26+
visit the files. With the full names, at least ~find-file-at-point~
27+
worked. Now even that only the filenames were in the leaf, navigation
28+
became painful again. The other alternative (retaining full path names
29+
in 2nd/3rd level headings) looked very ugly.
30+
31+
It was time to slip on some elisp gloves.
32+
33+
* How does org-fs-tree help?
34+
35+
- Takes a directory name from the user and creates a org-mode tree
36+
corresponding to the tree rooted at the directory.
37+
38+
- All the tree-folding goodness and short headings shall serve you
39+
well.
40+
41+
- Each heading is an org-mode link as well. ~C-c C-o~
42+
(~org-open-at-point) should serve you well for opening the files.
43+
44+
- Since even file names are headings, you can make notes under the
45+
file name
46+
47+
** Example
48+
49+
#+begin_src
50+
51+
$ tree ~/test/
52+
53+
/home/scriptdevil/test/
54+
|-- doc
55+
| |-- boo
56+
| |-- build-instructions.md
57+
| `-- running-tests.md
58+
|-- include
59+
| |-- bar.h
60+
| `-- foo.h
61+
|-- README
62+
`-- src
63+
|-- bar.c
64+
`-- foo.c
65+
66+
4 directories, 7 files
67+
#+end_src
68+
69+
70+
would in turn generate
71+
72+
#+begin_src
73+
74+
* [[/home/scriptdevil/test/][test/]]
75+
** [[/home/scriptdevil/test/README][README]]
76+
** [[/home/scriptdevil/test/doc/][doc/]]
77+
*** [[/home/scriptdevil/test/doc/boo/][boo/]]
78+
*** [[/home/scriptdevil/test/doc/build-instructions.md][build-instructions.md]]
79+
*** [[/home/scriptdevil/test/doc/running-tests.md][running-tests.md]]
80+
** [[/home/scriptdevil/test/include/][include/]]
81+
*** [[/home/scriptdevil/test/include/bar.h][bar.h]]
82+
*** [[/home/scriptdevil/test/include/foo.h][foo.h]]
83+
** [[/home/scriptdevil/test/src/][src/]]
84+
*** [[/home/scriptdevil/test/src/bar.c][bar.c]]
85+
*** [[/home/scriptdevil/test/src/foo.c][foo.c]]
86+
87+
#+end_src
88+
89+
I used this on the emacs source tree to generate
90+
[[examples/emacs-src.org]]
91+
92+
*Note:* This was just a dump of the entire tree, in reality, you may
93+
not care about some directories like ~nextstep/~ or ~msdos/~. In that
94+
case, you can delete the entire subtree with the regular org-mode
95+
operations. Also, this looks really ugly online because github doesn't
96+
let you fold subtrees. View this in emacs and you will see what I mean
97+
98+
Lastly, the links in this tree are rooted at /scratch/ because that is
99+
where I keep my emacs sources. Keeping full paths in all links lets
100+
you open the files with ~C-c C-o~ without having to consider what
101+
~$PWD~ is.
102+
103+
* Usage
104+
In any org-mode buffer:
105+
106+
M-x load-library ⏎ org-fs-tree
107+
M-x org-fs-tree-dump ⏎ /path/to/directory
108+
109+
110+
* Dependencies
111+
112+
[[https://github.com/Malabarba/names][names]] for providing a namespace for the functions defined
113+
[[https://github.com/rejeep/f.el][f]] for a really neat API to work with files and directories

0 commit comments

Comments
 (0)