|
@@ -7580,6 +7580,53 @@ This function can be used in a hook."
|
|
|
"ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
|
|
|
"BEGIN_EXAMPLE" "END_EXAMPLE"))
|
|
|
|
|
|
+(defcustom org-structure-template-alist
|
|
|
+ '(
|
|
|
+ ("s" "#+begin_src ?\n\n#+end_src")
|
|
|
+ ("e" "#+begin_example\n?\n#+end_example")
|
|
|
+ ("q" "#+begin_quote\n?\n#+end_quote")
|
|
|
+ ("v" "#+begin_verse\n?\n#+end_verse")
|
|
|
+ ("l" "#+begin_latex\n?\n#+end_latex")
|
|
|
+ ("L" "#+latex: ")
|
|
|
+ ("h" "#+begin_html\n?\n#+end_html")
|
|
|
+ ("H" "#+html: ")
|
|
|
+ ("a" "#+begin_ascii\n?\n#+end_ascii")
|
|
|
+ ("A" "#+ascii: ")
|
|
|
+ ("i" "#+include: %file ?")
|
|
|
+ )
|
|
|
+ "Structure completion elements.
|
|
|
+This is a list of abbreviation keys and values. The value gets inserted
|
|
|
+it you type @samp{.} followed by the key and then the completion key,
|
|
|
+usually `M-TAB'. %file will be replaced by a file name after prompting
|
|
|
+for the file uning completion.
|
|
|
+This is an experimental feature, it is undecided if it is going to stay in."
|
|
|
+ :group 'org-completion
|
|
|
+ :type '(repeat
|
|
|
+ (string :tag "Key") (string :tag "Template")))
|
|
|
+
|
|
|
+(defun org-complete-expand-structure-template (start cell)
|
|
|
+ "Expand a structure template."
|
|
|
+ (let ((rpl (nth 1 cell)))
|
|
|
+ (delete-region start (point))
|
|
|
+ (when (string-match "\\`#\\+" rpl)
|
|
|
+ (cond
|
|
|
+ ((bolp))
|
|
|
+ ((not (string-match "\\S-" (buffer-substring (point-at-bol) (point))))
|
|
|
+ (delete-region (point-at-bol) (point)))
|
|
|
+ (t (newline))))
|
|
|
+ (setq start (point))
|
|
|
+ (if (string-match "%file" rpl)
|
|
|
+ (setq rpl (replace-match
|
|
|
+ (concat
|
|
|
+ "\""
|
|
|
+ (save-match-data
|
|
|
+ (abbreviate-file-name (read-file-name "Include file: ")))
|
|
|
+ "\"")
|
|
|
+ t t rpl)))
|
|
|
+ (insert rpl)
|
|
|
+ (if (re-search-backward "\\?" start t) (delete-char 1))))
|
|
|
+
|
|
|
+
|
|
|
(defun org-complete (&optional arg)
|
|
|
"Perform completion on word at point.
|
|
|
At the beginning of a headline, this completes TODO keywords as given in
|
|
@@ -7594,7 +7641,8 @@ At all other locations, this simply calls the value of
|
|
|
(interactive "P")
|
|
|
(org-without-partial-completion
|
|
|
(catch 'exit
|
|
|
- (let* ((end (point))
|
|
|
+ (let* ((a nil)
|
|
|
+ (end (point))
|
|
|
(beg1 (save-excursion
|
|
|
(skip-chars-backward (org-re "[:alnum:]_@"))
|
|
|
(point)))
|
|
@@ -7603,6 +7651,12 @@ At all other locations, this simply calls the value of
|
|
|
(point)))
|
|
|
(confirm (lambda (x) (stringp (car x))))
|
|
|
(searchhead (equal (char-before beg) ?*))
|
|
|
+ (struct
|
|
|
+ (when (and (equal (char-before beg1) ?.)
|
|
|
+ (setq a (assoc (buffer-substring beg1 (point))
|
|
|
+ org-structure-template-alist)))
|
|
|
+ (org-complete-expand-structure-template (1- beg1) a)
|
|
|
+ (throw 'exit t)))
|
|
|
(tag (and (equal (char-before beg1) ?:)
|
|
|
(equal (char-after (point-at-bol)) ?*)))
|
|
|
(prop (and (equal (char-before beg1) ?:)
|