org-cycle: Throw an error when `org-cycle-max-level' is not positive

* lisp/org-cycle.el (org-cycle): Avoid cryptic regexp error when
`org-cycle-max-level' is not set to positive integer.

Reported-by: Alain.Cochard@unistra.fr
Link: https://orgmode.org/list/25496.14797.512207.593382@gargle.gargle.HOWL
This commit is contained in:
Ihor Radchenko 2024-01-09 15:24:16 +01:00
parent 97951352bb
commit 0773f4980c
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 0 deletions

View File

@ -336,6 +336,10 @@ same as `S-TAB') also when called without prefix argument."
(and org-cycle-level-after-item/entry-creation
(or (org-cycle-level)
(org-cycle-item-indentation))))
(when (and org-cycle-max-level
(or (not (integerp org-cycle-max-level))
(< org-cycle-max-level 1)))
(user-error "`org-cycle-max-level' must be a positive integer"))
(let* ((limit-level
(or org-cycle-max-level
(and (boundp 'org-inlinetask-min-level)