Rasmus <ras...@gmx.us> writes:

> Hi Eric,
>
> Eric Abrahamsen <e...@ericabrahamsen.net> writes:
>
>>> Also, Eric, it seems that org-structure-template-alist only supports a
>>> single letter for short-hands (the car of an entry in
>>> org-structure-template-alist is a char).  I used to have blocks like "<ab"
>>> expanding to an "abstract" special-block, which I guess isn’t possible
>>> anymore?
>>
>> I hadn't thought of that. Really, all I ever wanted was to wrap things
>> in blocks...
>>
>> I don't see any reason why org-structure-template-alist couldn't go back
>> to using string keys. Then we could use read-string, and wouldn't have
>> to have special <TAB> behavior -- a string that didn't exist in the
>> alist could just be used literally to make a block.
>
> I’d prefer that.  For some special blocks, a few characters might makes it
> more intuitive, e.g. "def" → "definition", "hyp" → "hypothesis" etc.

Here's the simplest solution. 

There still remains the fact that `org-structure-template-alist' has
changed format, and `org-try-structure-completion' no longer exists.
That may still annoy some people who were using the internals of the
process, but...

diff --git a/lisp/org.el b/lisp/org.el
index f873f1021..7c451d525 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11857,42 +11857,40 @@ keywords relative to each registered export back-end."
     "TITLE:" "TODO:" "TYP_TODO:" "SELECT_TAGS:" "EXCLUDE_TAGS:"))
 
 (defcustom org-structure-template-alist
-  '((?a . "export ascii")
-    (?c . "center")
-    (?C . "comment")
-    (?e . "example")
-    (?E . "export")
-    (?h . "export html")
-    (?l . "export latex")
-    (?q . "quote")
-    (?s . "src")
-    (?v . "verse"))
+  '(("a" . "export ascii")
+    ("c" . "center")
+    ("C" . "comment")
+    ("e" . "example")
+    ("E" . "export")
+    ("h" . "export html")
+    ("l" . "export latex")
+    ("q" . "quote")
+    ("s" . "src")
+    ("v" . "verse"))
   "Structure completion elements.
 This is an alist of characters and values.  When
-`org-insert-structure-template' is called, an additional key is
-read.  The key is first looked up in this alist, and the
-corresponding structure is inserted, with \"#+BEGIN_\" and
-\"#+END_\" added automatically."
+`org-insert-structure-template' is called, a string key is read.
+The key is first looked up in this alist, and the corresponding
+structure is inserted, with \"#+BEGIN_\" and \"#+END_\" added
+automatically."
   :group 'org-completion
   :type '(repeat
-	  (cons (character :tag "Key")
+	  (cons (string :tag "Key")
 		(string :tag "Template")))
   :package-version '(Org . "9.2"))
 
 (defun org-insert-structure-template (type)
   "Insert a block structure of the type #+begin_foo/#+end_foo.
-First read a character, which can be one of the keys in
-`org-structure-template-alist'.  When it is <TAB>, prompt the
-user for a string to use.  With an active region, wrap the region
-in the block.  Otherwise, insert an empty block."
+First read a string, which is used as a lookup key in
+`org-structure-template-alist' or, failing that, used literally.
+With an active region, wrap the region in the block.  Otherwise,
+insert an empty block."
   (interactive
    (list
-    (let* ((key (read-key "Key: "))
+    (let* ((key (read-string "Key: "))
 	   (struct-string
-	    (or (cdr (assq key org-structure-template-alist))
-		(and (= key ?\t)
-		     (read-string "Structure type: "))
-		(user-error "`%c' has no structure definition" key))))
+	    (or (cdr (assoc-string key org-structure-template-alist))
+		key)))
       struct-string)))
   (let* ((region? (use-region-p))
 	 (s (if region? (region-beginning) (point)))

Reply via email to