Rename option auto-id' to unique-id'

This commit is contained in:
Lucien Cartier-Tilet 2022-09-01 16:26:30 +02:00
parent 8633b3b83b
commit f8e68356d1
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 14 additions and 8 deletions

View File

@ -14,6 +14,8 @@ user modifies them manually.
- [[#introduction][Introduction]] - [[#introduction][Introduction]]
- [[#installation][Installation]] - [[#installation][Installation]]
- [[#usage][Usage]] - [[#usage][Usage]]
- [[#breaking-changes][Breaking changes]]
- [[#040][~0.4.0~]]
- [[#contributing][Contributing]] - [[#contributing][Contributing]]
- [[#license][License]] - [[#license][License]]
@ -49,12 +51,12 @@ 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 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 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 instance for a bit. Therefore, automatic IDs are enabled on a per-file
basis with the option ~auto-id~. basis with the option ~unique-id~.
Here is an example of an org buffer with ~org-unique-id~ enabled: Here is an example of an org buffer with ~org-unique-id~ enabled:
#+begin_src org #+begin_src org
,#+title: Test file ,#+title: Test file
,#+options: auto-id:t ,#+options: unique-id:t
,* Test level 1 ,* Test level 1
:PROPERTIES: :PROPERTIES:
@ -77,7 +79,7 @@ the ~CUSTOM_ID~ and let ~org-unique-id~ regenerate it. If you dont like
the ~CUSTOM_ID~ generated by ~org-unique-id~, you can overwrite it the ~CUSTOM_ID~ generated by ~org-unique-id~, you can overwrite it
yourself and ~org-unique-id~ will not modify it. yourself and ~org-unique-id~ will not modify it.
Note that ~auto-id:t~ is absolutely required in order to get these Note that ~unique-id:t~ is absolutely required in order to get these
~CUSTOM_ID~. Here is the same buffer after save without this option: ~CUSTOM_ID~. Here is the same buffer after save without this option:
#+begin_src org #+begin_src org
,#+title: Test file ,#+title: Test file
@ -88,7 +90,11 @@ Note that ~auto-id:t~ is absolutely required in order to get these
It is also possible to manually call ~org-unique-id~ (interactively or 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 not) on the current buffer. This will not check the value of the
~auto-id~ option. ~unique-id~ option.
* Breaking changes
** ~0.4.0~
The option ~auto-id~ is renamed to ~unique-id~.
* Contributing * Contributing
See [[file:CONTRIBUTING.org]]. See [[file:CONTRIBUTING.org]].

View File

@ -112,8 +112,8 @@ case, the CUSTOM_ID of the entry is returned."
(defun org-unique-id () (defun org-unique-id ()
"Add a CUSTOM_ID to all headers missing one. "Add a CUSTOM_ID to all headers missing one.
Only adds ids if the `auto-id' option is set to t in the file Only adds ids if the \\='unique-id\\=' option is set to t in the
somewhere, i.e. #+OPTIONS: auto-id:t" file somewhere, i.e. #+OPTIONS: unique-id:t"
(interactive) (interactive)
(save-excursion (save-excursion
(widen) (widen)
@ -126,14 +126,14 @@ somewhere, i.e. #+OPTIONS: auto-id:t"
This function executes `org-unique-id' when the buffers major This function executes `org-unique-id' when the buffers major
mode is `org-mode', when the buffer is not read-only, and if mode is `org-mode', when the buffer is not read-only, and if
\\='auto-id:t\\' is found in an #+OPTIONS line." \\='unique-id:t\\' is found in an #+OPTIONS line."
(interactive) (interactive)
(when (and (eq major-mode 'org-mode) (when (and (eq major-mode 'org-mode)
(not buffer-read-only) (not buffer-read-only)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(let ((case-fold-search t)) (let ((case-fold-search t))
(re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)))) (re-search-forward "^#\\+OPTIONS:.*unique-id:t" (point-max) t))))
(org-unique-id))) (org-unique-id)))
(provide 'org-unique-id) (provide 'org-unique-id)