Skip to content

Commit 3f8ad57

Browse files
author
George Moutsopoulos
committed
Readme
1 parent 6f351b0 commit 3f8ad57

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

Readme.org

+36-16
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ The annotation can be made using a capture template with the function ~org-annot
1717
#+begin_src
1818
("a" "Annotate" plain #'org-annotate-code-capture-finding-location "%?")
1919
#+end_src
20-
Without further configuration, org-capture will use the default annotator.
20+
Without further configuration, this template will use the default annotator.
2121

2222
There are annotators for specific modes. For instance, to annotate python files
2323
#+begin_src
2424
(require 'org-annotate-python)
2525
#+end_src
26-
This will associate all python files with this annotator when you use the generic capture function above. The capture mode will then make specific links for python, where the first level is the filename in dotted form and the second and deeper levels are nested headings with python function/class/variable names. Registering for a major mode is done by modifying the alist ~org-annotate-code-info-alist~, eg
26+
This will associate all python files with the python annotator when using the generic capture template. The python annotation will make specific links, eg to the python function that is annotated. Registering for a major mode is done by modifying the alist ~org-annotate-code-info-alist~, eg
2727
#+begin_src
2828
(add-to-list 'org-annotate-code-info-alist (cons 'python-mode 'org-annotate-python-info-at-point))
2929
#+end_src
@@ -33,44 +33,57 @@ If you want to use word annotations by default then
3333
#+begin_src
3434
(setq org-annotate-code-info-default 'org-annotate-word-info-at-point)
3535
#+end_src
36-
will make annotations that point to the word at the position in the file. This annotator defines a new link of type "word". Functions such as ~org-annotate-python-info-at-point~ or ~org-annotate-word-info-at-point~ are at the core of what is an annotator. You can also override the default annotator in ~org-annotate-code-info-default~ with the local variable ~org-annotate-code-info-override~. For this, you will need to know the annotator's function name, eg in a given buffer
36+
will make annotations that point to the annotated word at (or near) a position in the file.
37+
38+
Functions such as ~org-annotate-python-info-at-point~ or ~org-annotate-word-info-at-point~ are at the core of what is an annotator. You can also override the default annotator with the local variable ~org-annotate-code-info-override~. For this, you will need to know the annotator's function name, eg in a given buffer
3739
#+begin_src
3840
(setq org-annotate-code-info-override 'org-annotate-word-info-at-point)
3941
#+end_src
4042
this becomes a local buffer variable. Setting dir-locals.el can make use of different annotators per file.
4143

42-
Alternatively, you can remove python from the alist above and use a separate special template for python in the ~org-capture~templates~, eg
44+
Finally, you can remove python from the alist above and use a separate special template for python in the ~org-capture~templates~, eg
4345
#+begin_src
4446
("p" "Python" plain #'org-annotate-python-capture-finding-location "%?")
4547
#+end_src
46-
For this, you will need to know the name of the capture finding location. For each annotator there is one annotator function that can be used with the generic capure finding function and one special capture finding location (which simply wraps the generic function with the override variable).
48+
For this, you will need to know the name of the capture finding location. For each annotator there is one annotator function like ~org-annotate-python-info-at-point~ and one special capture finding function like ~org-annotate-python-capture-finding-location~. The first is used to modify the generic template, the latter is used in a special org-capture template.
4749

4850
One can insert a top-level heading, either globally or per file, by setting ~org-annotate-code-heading0~. Beyond this level, typically the top-level heading is the filename, but ultimately this depends on the annotator used. One can also customize the annotation file locally by setting ~org-annotation-code-org-file~. So for instance, each project can save annotations under a different top-level heading in the same file, or in separate files per project, or any combination defined in dir-locals.el.
4951

5052
An annotator that annotates the word at point is defined in ~org-annotate-word~. This creates links that point to a word at a position in a file, and by default clicking on the link takes one to the nearest word at that position. If the minor mode ~org-annotate-live-mode~ is loaded while the annotated file is edited, it will change the ~CUSTOM_ID~ so that the positions are corrected. This is work in progress.
5153

52-
There can be arbitrary nodes of the annotation tree. The annotator functions return a list of nodes and each node is a plist with keys ~:id~ and ~:heading~ and possibly ~:properties~. The top-level heading is inserted after these annotators have done their work.
54+
There can be arbitrary nodes of the annotation tree, depending on the annotator used. The annotator functions return a list of nodes and each node is a plist with keys ~:id~ and ~:heading~ and possibly ~:properties~. The top-level heading is inserted after these annotators have done their work. It is then possible to extend ~org-annotate-code~ by writing such functions.
5355

54-
Once the annotation is created, the custom id links should not be changed but the headings can change at will. The whole tree can be moved and/or demoted somewhere else in the annotation file. If an annotation at the same place is triggered, there are two options to search for the annotation tree:
56+
Once the annotation is created, the custom id links should not be changed but the headings can change at will. The whole tree can be moved and/or demoted somewhere else in the annotation file. If an annotation at the same place is triggered, there are two options to search for the annotation tree in the org file:
5557
- a bottom-top search that places importance on the last custom id to exist
5658
- a top-bottom search that places importance on the whole hierarchy of custom ids to exist
57-
Either the moved entry is found by its id or a new hierarchy of items will be created where the search fails. To customize which of these two methods is used, see ~org-annotate-code-search-annotation-method~.
59+
Either the moved entry is found by its id or a new hierarchy of items will be created. To customize which of these two methods is used, see ~org-annotate-code-search-annotation-method~.
5860

5961
* Annotators
6062
** Line numbers
61-
Creates a tree structure like ~file name -> line number~. This can be achieved out of the box with org-mode.
63+
Creates a tree structure like ~file name -> line number~. This can be achieved out of the box with org-mode. It is loaded by default and is the default annotator.
6264
** python
63-
An annotation might look like the nested headings ~file name -> function definition -> local variable~ or ~filename -> global variable~. Links are possible by defining a new link type called pydef, eg ~[[pydef:filename.py::newfun.newsubfun.localvariable]]~.
65+
#+begin_src
66+
(require 'org-annotate-python)
67+
#+end_src
68+
69+
An annotation might look like the nested headings ~file name -> function definition -> local variable~ or ~filename -> global variable~. Links are possible by defining a new link type, eg ~[[pydef:filename.py::newfun.newsubfun.localvariable]]~. Clicking on the link will try to find the definition in nested python blocks.
6470

6571
When creating an annotation, the user can select what is to be annotated, eg ~newfun~, ~newfun.newsubfun~ or ~newfun.newsubfun.localvariable~. If the user chooses to annotate ~newfun.newsubfun~ then the annotation will have hierarchy ~filename.py -> newfun -> newfun.newsubfun~. One can customize these settings by changing ~org-annotate-python-squash-annotation-level~ and ~org-annotate-python-squash-candidates-level~.
6672

67-
It is possible to use relative path headings using projectile. Filename headings are dotted by default as in python modules.
73+
The first level heading is a filename. It is possible to use relative paths using projectile. Filename headings are dotted by default as in python modules, but this can be changed.
6874

6975
** dired
70-
Use ~org-annotate-code-info-at-point-dired~.
71-
Allows to annotate the file at point in dired. The annotations will still be in ~org-annotate-code-org-file~ and under the top-level heading if set.
76+
An annotator function is register to dired buffers when loading
77+
#+begin_src
78+
(require 'org-annotate-dired)
79+
#+end_src
80+
It allows to annotate the file at point in dired. The annotations will still be in ~org-annotate-code-org-file~ and under the top-level heading if set.
7281
** word
73-
This creates a link like ~[[word:filename::position::word]]~ that searches for the word near a line number in a file.
82+
To use, load
83+
#+begin_src
84+
(require 'org-annotate-word)
85+
#+end_src
86+
This creates a link like ~[[word:filename::position::word]]~ that searches for the word near a line number in a file. It will not register with any modes by default.
7487

7588
This annotator will keep track of line numbers changes if the text is changed while ~org-annotate-live-mode~ is loaded. It will change the org-file accordingly each time
7689
- The file is saved
@@ -80,11 +93,18 @@ However, if you use the live mode, currently, link ids will be renamed to stale
8093

8194
You can also checkout [[https://github.com/bastibe/annotate.el][annotation-mode]], a maturer project, for live changing the line numbers as text is edited.
8295
** index
83-
Use ~org-annotate-code-info-at-point-index~.
84-
Allows adding the file name, either the current buffer or the file pointed at in dired, in an ~index.org~ file in the /same/ directory as the file. That is ~org-annotate-code-org-file~ or the top-level heading is not used here. This does not register an annotator with the ~org-annotate-code-info-alist~. One would add ~org-annotate-index-capture-finding-location~ in a sepratate capure template, as in
96+
To start using
97+
#+begin_src
98+
(require 'org-annotate-index)
99+
#+end_src
100+
Allows adding the file name, either the current buffer or the file pointed at in dired, in an ~index.org~ file in the /same/ directory as the file. That is ~org-annotate-code-org-file~ or the top-level heading is not used here.
101+
102+
The annotator function is ~org-annotate-code-info-at-point-index~ but it shouldn't be used.
103+
This does not register an annotator with the ~org-annotate-code-info-alist~. One would add ~org-annotate-index-capture-finding-location~ in a sepratate capure template, as in
85104
#+begin_src
86105
("i" "Insert file to index" plain #'org-annotate-index-capture-finding-location "%?")
87106
#+end_src
107+
You can then start building an index with descriptions of your files in each directory.
88108
* Similar Packages
89109
If you know of similar packages, please let me know
90110
- ~org-annotate-file~ is similar, but ~org-annotate-code~ is presently configurable

0 commit comments

Comments
 (0)