summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus <rasmus@gmx.us>2018-05-27 14:44:49 +0200
committerRasmus <rasmus@gmx.us>2018-05-28 23:44:51 +0200
commit7ac46c52b770bb40d8f14a343e5417186ec7bc66 (patch)
treebc13c78de8c90823ecbe57684bcabe60ee78b000
parentdac180ea0d4efa143ea8408cd5a04f7f7da444fe (diff)
downloadorg-mode-7ac46c52b770bb40d8f14a343e5417186ec7bc66.tar.gz
Check format of org-structure-template-alist
* org.el (org--check-org-structure-template-alist): New function yielding user-error if using old org-structure-template-alist format. (org--insert-structure-template-mks): * org-tempo.el (org-tempo-add-templates): Use new function
-rw-r--r--lisp/org-tempo.el2
-rw-r--r--lisp/org.el30
2 files changed, 32 insertions, 0 deletions
diff --git a/lisp/org-tempo.el b/lisp/org-tempo.el
index b9a554f..a651c7b 100644
--- a/lisp/org-tempo.el
+++ b/lisp/org-tempo.el
@@ -102,6 +102,8 @@ Tempo templates will be added."
Go through `org-structure-template-alist' and
`org-tempo-keywords-alist' and update tempo templates."
+ (mapc 'org--check-org-structure-template-alist '(org-structure-template-alist
+ org-tempo-keywords-alist))
(let ((keys (org-tempo--keys)))
;; Check for duplicated snippet keys and warn if any are found.
(when (> (length keys) (length (delete-dups keys)))
diff --git a/lisp/org.el b/lisp/org.el
index e0dc8d7..672ce15 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11727,6 +11727,35 @@ block can be inserted by pressing TAB after the string \"<KEY\"."
(string :tag "Template")))
:package-version '(Org . "9.2"))
+(defun org--check-org-structure-template-alist (&optional checklist)
+ "Check whether `org-structure-template-alist' is set up correctly.
+In particular, check if the Org 9.2 format is used as opposed to
+previous format.
+"
+ (let ((elm (cl-remove-if-not (lambda (x) (listp (cdr x)))
+ (or (eval checklist)
+ org-structure-template-alist))))
+ (when elm
+ (org-display-warning
+ (format "
+Please update the entries of `%s'.
+
+In Org 9.2 the format was changed from something like
+
+ (\"s\" \"#+BEGIN_SRC ?\\n#+END_SRC\")
+
+to something like
+
+ (\"s\" . \"src\")
+
+Please refer to the documentation of `org-structure-template-alist'.
+
+The following entries must be updated:
+
+%s"
+ (or checklist 'org-structure-template-alist)
+ (pp-to-string elm))))))
+
(defun org--insert-structure-template-mks ()
"Present `org-structure-template-alist' with `org-mks'.
@@ -11734,6 +11763,7 @@ Menus are added if keys require more than one keystroke. Tabs
are added to single key entries when more than one stroke is
needed. Keys longer than two characters are reduced to two
characters."
+ (org--check-org-structure-template-alist)
(let* (case-fold-search
(templates (append org-structure-template-alist
'(("\t" . "Press TAB, RET or SPC to write block name"))))