Browse Source

Add an easy template for index (i)

* lisp/org.el (org-structure-template-alist):  Add an easy template
for index (i), and move include file to I from i.
* doc/org.texi (Easy Templates): Document new template.

Notes about this patch:
1.  It breaks some old user-visible behavior, since <i changes meaning.
    Per Nick's posting, we expect that if index is used, it will be used
    more commonly than include file.  However, since this is a custom,
    behavior could be changed.  Indeed, we could put index on capital
    I with a suggestion that users who are indexing should swap in their
2.  I modified the docstring for org-structure-template-alist, which did
    not explain the function of the "?" in the string.  Someone should
    check and verify I didn't get this wrong.
3.  There doesn't seem to be a Muse tag equivalent for #+index, so I
    just made the Muse equivalent of #+index be #+index.  I don't know
    org-mtags enough to know if this is appropriate.
Robert P. Goldman 9 years ago
2 changed files with 8 additions and 4 deletions
  1. 2 1
  2. 6 3

+ 2 - 1

@@ -12976,7 +12976,8 @@ The following template selectors are currently supported.
 @item @kbd{H} @tab @code{#+html:}
 @item @kbd{a} @tab @code{#+begin_ascii   ... #+end_ascii}
 @item @kbd{A} @tab @code{#+ascii:}
-@item @kbd{i} @tab @code{#+include:} line
+@item @kbd{i} @tab @code{#+index:} line
+@item @kbd{I} @tab @code{#+include:} line
 @end multitable
 For example, on an empty line, typing "<e" and then pressing TAB, will expand

+ 6 - 3

@@ -10760,14 +10760,17 @@ This function can be used in a hook."
          "<literal style=\"html\">?</literal>")
     ("a" "#+begin_ascii\n?\n#+end_ascii")
     ("A" "#+ascii: ")
-    ("i" "#+include %file ?"
+    ("i" "#+index: ?"
+     "#+index: ?")
+    ("I" "#+include %file ?"
          "<include file=%file markup=\"?\">")
   "Structure completion elements.
 This is a list of abbreviation keys and values.  The value gets inserted
 if you type `<' followed by the key and then press the completion key,
 usually `M-TAB'.  %file will be replaced by a file name after prompting
-for the file using completion.
+for the file using completion.  The cursor will be placed at the position
+of the `?` in the template.
 There are two templates for each key, the first uses the original Org syntax,
 the second uses Emacs Muse-like syntax tags.  These Muse-like tags become
 the default when the /org-mtags.el/ module has been loaded.  See also the
@@ -10786,7 +10789,7 @@ expands them."
   (let ((l (buffer-substring (point-at-bol) (point)))
     (when (and (looking-at "[ \t]*$")
-	       (string-match "^[ \t]*<\\([a-z]+\\)$"l)
+	       (string-match "^[ \t]*<\\([a-zA-Z]+\\)$" l)
 	       (setq a (assoc (match-string 1 l) org-structure-template-alist)))
       (org-complete-expand-structure-template (+ -1 (point-at-bol)
 						 (match-beginning 1)) a)