org-num-mode: Clear remaining num overlays before activation

* lisp/org-num.el (org-num-mode): Call `org-num--clear' when enabling
the mode.  This avoids duplicate overlays when the mode was active
prior (org-num-mode +1) call.

Reported-by: Ruijie Yu
Link: https://orgmode.org/list/sdvbkq8a7lp.fsf@fw.net.yu
This commit is contained in:
Ihor Radchenko 2022-10-20 12:50:41 +08:00
parent a7a579d06a
commit 7f8e616f3b
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 1 additions and 0 deletions

View File

@ -461,6 +461,7 @@ NUMBERING is a list of numbers."
(org-num-mode
(unless (derived-mode-p 'org-mode)
(user-error "Cannot activate headline numbering outside Org mode"))
(org-num--clear)
(setq org-num--numbering nil)
(setq org-num--overlays (nreverse (org-num--number-region nil nil)))
(add-hook 'after-change-functions #'org-num--verify nil t)