2021-06-15 16:30:11 +00:00
|
|
|
|
#+title: org-unique-id
|
|
|
|
|
#+author: Lucien Cartier-Tilet
|
|
|
|
|
#+email: lucien@phundrak.com
|
2022-08-24 01:31:06 +00:00
|
|
|
|
[[https://github.com/Phundrak/org-unique-id/actions/workflows/workflow.yml][file:https://github.com/Phundrak/org-unique-id/actions/workflows/workflow.yml/badge.svg]]
|
2022-09-04 12:34:03 +00:00
|
|
|
|
[[https://melpa.org/#/org-unique-id][file:https://melpa.org/packages/org-unique-id-badge.svg]]
|
|
|
|
|
[[https://stable.melpa.org/#/org-unique-id][file:https://stable.melpa.org/packages/org-unique-id-badge.svg]]
|
2021-06-15 16:30:11 +00:00
|
|
|
|
|
|
|
|
|
* Introduction
|
|
|
|
|
~org-unique-id~ is a utility package for org users that are tired
|
|
|
|
|
dealing with random org IDs for their headers that change on each org
|
|
|
|
|
to HTML export (and other kinds of exports). This package creates
|
|
|
|
|
meaningful custom IDs for org headers that won’t change unless the
|
|
|
|
|
user modifies them manually.
|
|
|
|
|
|
|
|
|
|
* Table of Contents :TOC_2_gh:
|
|
|
|
|
- [[#introduction][Introduction]]
|
|
|
|
|
- [[#installation][Installation]]
|
2022-08-24 00:51:08 +00:00
|
|
|
|
- [[#usage][Usage]]
|
2022-09-01 14:26:30 +00:00
|
|
|
|
- [[#breaking-changes][Breaking changes]]
|
|
|
|
|
- [[#040][~0.4.0~]]
|
2021-06-15 16:30:11 +00:00
|
|
|
|
- [[#contributing][Contributing]]
|
|
|
|
|
- [[#license][License]]
|
|
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
|
This package can be installed like any other simple package. Your
|
|
|
|
|
first option is to download ~org-unique-id~ or clone this package in
|
|
|
|
|
your ~load-path~ and add the following to your configuration:
|
|
|
|
|
#+begin_src emacs-lisp
|
2022-08-24 00:51:08 +00:00
|
|
|
|
(require 'org-unique-id)
|
|
|
|
|
(add-hook 'before-save-hook #'org-unique-id-maybe)
|
2021-06-15 16:30:11 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
You can also use a package manager such as Quelpa or Straight in order
|
|
|
|
|
to load automatically your package. In my case, I prefer the latter
|
|
|
|
|
with its ~use-package~ integration:
|
|
|
|
|
#+begin_src emacs-lisp
|
2022-08-24 00:51:08 +00:00
|
|
|
|
(use-package org-unique-id
|
|
|
|
|
:require t
|
|
|
|
|
:after org
|
|
|
|
|
:straight (org-unique-id :type git
|
|
|
|
|
:host github
|
|
|
|
|
:repo "Phundrak/org-unique-id")
|
|
|
|
|
:init (add-hook 'before-save-hook #'org-unique-id-maybe))
|
2021-06-15 16:30:11 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
|
2022-08-24 00:51:08 +00:00
|
|
|
|
I personally add ~:build t~ to my straight recipe to ensure my package is compiled.
|
2021-06-15 16:30:11 +00:00
|
|
|
|
|
|
|
|
|
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!
|
|
|
|
|
|
2022-08-24 00:51:08 +00:00
|
|
|
|
* Usage
|
|
|
|
|
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
|
2022-09-01 14:26:30 +00:00
|
|
|
|
basis with the option ~unique-id~.
|
2022-08-24 00:51:08 +00:00
|
|
|
|
|
|
|
|
|
Here is an example of an org buffer with ~org-unique-id~ enabled:
|
|
|
|
|
#+begin_src org
|
|
|
|
|
,#+title: Test file
|
2022-09-01 14:26:30 +00:00
|
|
|
|
,#+options: unique-id:t
|
2022-08-24 00:51:08 +00:00
|
|
|
|
|
|
|
|
|
,* 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.
|
|
|
|
|
|
2022-09-01 14:26:30 +00:00
|
|
|
|
Note that ~unique-id:t~ is absolutely required in order to get these
|
2022-08-24 00:51:08 +00:00
|
|
|
|
~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
|
2022-09-01 14:26:30 +00:00
|
|
|
|
~unique-id~ option.
|
|
|
|
|
|
|
|
|
|
* Breaking changes
|
|
|
|
|
** ~0.4.0~
|
|
|
|
|
The option ~auto-id~ is renamed to ~unique-id~.
|
2021-06-15 16:30:11 +00:00
|
|
|
|
|
|
|
|
|
* Contributing
|
|
|
|
|
See [[file:CONTRIBUTING.org]].
|
|
|
|
|
|
|
|
|
|
* License
|
|
|
|
|
~org-unique-id~ is available under the GNU GPL-3.0 license. You can find
|
|
|
|
|
the full text in [[file:LICENSE.md][LICENSE.md]].
|