Update instructions in README
This commit is contained in:
parent
975311184a
commit
5d94c667db
68
README.org
68
README.org
@ -12,6 +12,7 @@ user modifies them manually.
|
|||||||
* Table of Contents :TOC_2_gh:
|
* Table of Contents :TOC_2_gh:
|
||||||
- [[#introduction][Introduction]]
|
- [[#introduction][Introduction]]
|
||||||
- [[#installation][Installation]]
|
- [[#installation][Installation]]
|
||||||
|
- [[#usage][Usage]]
|
||||||
- [[#contributing][Contributing]]
|
- [[#contributing][Contributing]]
|
||||||
- [[#license][License]]
|
- [[#license][License]]
|
||||||
|
|
||||||
@ -21,13 +22,7 @@ first option is to download ~org-unique-id~ or clone this package in
|
|||||||
your ~load-path~ and add the following to your configuration:
|
your ~load-path~ and add the following to your configuration:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(require 'org-unique-id)
|
(require 'org-unique-id)
|
||||||
(add-hook 'org-mode-hook
|
(add-hook 'before-save-hook #'org-unique-id-maybe)
|
||||||
(lambda ()
|
|
||||||
(add-hook 'before-save-hook
|
|
||||||
(lambda ()
|
|
||||||
(when (and (eq major-mode 'org-mode)
|
|
||||||
(eq buffer-read-only nil))
|
|
||||||
(org-unique-id))))))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
You can also use a package manager such as Quelpa or Straight in order
|
You can also use a package manager such as Quelpa or Straight in order
|
||||||
@ -40,24 +35,59 @@ with its ~use-package~ integration:
|
|||||||
:straight (org-unique-id :type git
|
:straight (org-unique-id :type git
|
||||||
:host github
|
:host github
|
||||||
:repo "Phundrak/org-unique-id")
|
:repo "Phundrak/org-unique-id")
|
||||||
:init
|
:init (add-hook 'before-save-hook #'org-unique-id-maybe))
|
||||||
(add-hook 'org-mode-hook
|
|
||||||
(lambda ()
|
|
||||||
(add-hook 'before-save-hook
|
|
||||||
(lambda ()
|
|
||||||
(when (and (eq major-mode 'org-mode)
|
|
||||||
(eq buffer-read-only nil))
|
|
||||||
(org-unique-id)))))))
|
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
I also add ~:build t~ to my straight recipe to ensure my package is compiled.
|
I personally add ~:build t~ to my straight recipe to ensure my package is compiled.
|
||||||
|
|
||||||
If you know how to handle this with a pure Straight recipe, or with a
|
If you know how to handle this with a pure Straight recipe, or with a
|
||||||
Quelpa recipe, don’t hesitate to submit a PR to add it to this README!
|
Quelpa recipe, don’t hesitate to submit a PR to add it to this README!
|
||||||
|
|
||||||
Also, DAMN that’s one hell of a hook, if you know anything simpler
|
* Usage
|
||||||
than this, please submit it!
|
While ~org-unique-id~ may be installed on your Emacs instance, it is not
|
||||||
|
active by default. This is because it can take some time to generate
|
||||||
|
all the required IDs in your org file which may hang your Emacs
|
||||||
|
instance for a bit. Therefore, automatic IDs are enabled on a per-file
|
||||||
|
basis with the option ~auto-id~.
|
||||||
|
|
||||||
|
Here is an example of an org buffer with ~org-unique-id~ enabled:
|
||||||
|
#+begin_src org
|
||||||
|
,#+title: Test file
|
||||||
|
,#+options: auto-id:t
|
||||||
|
|
||||||
|
,* Test level 1
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: Test-level-1-zmb40t305kj0
|
||||||
|
:END:
|
||||||
|
,** Test level 2
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: Test-level-1-Test-level-2-spn40t305kj0
|
||||||
|
:END:
|
||||||
|
,* Test level 1
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: Test-level-1-1nx40t305kj0
|
||||||
|
:END:
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
The ~CUSTOM_ID~ properties are generated on save and only once. Once the
|
||||||
|
~CUSTOM_ID~ of a heading is set, the package will not modify it even if
|
||||||
|
the name of the heading itself is modified. To regenerate it, delete
|
||||||
|
the ~CUSTOM_ID~ and let ~org-unique-id~ regenerate it. If you don’t like
|
||||||
|
the ~CUSTOM_ID~ generated by ~org-unique-id~, you can overwrite it
|
||||||
|
yourself and ~org-unique-id~ will not modify it.
|
||||||
|
|
||||||
|
Note that ~auto-id:t~ is absolutely required in order to get these
|
||||||
|
~CUSTOM_ID~. Here is the same buffer after save without this option:
|
||||||
|
#+begin_src org
|
||||||
|
,#+title: Test file
|
||||||
|
,* Test level 1
|
||||||
|
,** Test level 2
|
||||||
|
,* Test level 1
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
It is also possible to manually call ~org-unique-id~ (interactively or
|
||||||
|
not) on the current buffer. This will not check the value of the
|
||||||
|
~auto-id~ option.
|
||||||
|
|
||||||
* Contributing
|
* Contributing
|
||||||
See [[file:CONTRIBUTING.org]].
|
See [[file:CONTRIBUTING.org]].
|
||||||
|
Loading…
Reference in New Issue
Block a user