org-insert-structure-template: Err on empty TYPE

* lisp/org.el (org-insert-structure-template): Throw a user error on
empty TYPE input.  Throw an error when TYPE is not a string or an
empty string.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
This commit is contained in:
Ihor Radchenko 2023-07-01 13:20:58 +03:00
parent 85aa3c1850
commit 64a0a624d2
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 1 deletions

View File

@ -9063,8 +9063,13 @@ block.
When foo is written as FOO, upcase the #+BEGIN/END as well."
(interactive
(list (pcase (org--insert-structure-template-mks)
(`("\t" . ,_) (read-string "Structure type: "))
(`("\t" . ,_)
(let ((type (read-string "Structure type: ")))
(when (string-empty-p type) (user-error "Empty structure type"))
type))
(`(,_ ,choice . ,_) choice))))
(when (or (not (stringp type)) (string-empty-p type))
(error "Invalid structure type: %S" type))
(let* ((case-fold-search t) ; Make sure that matches are case-insensitive.
(region? (use-region-p))
(region-start (and region? (region-beginning)))