Selaa lähdekoodia

Insert block templates indented to cursor cookie position

When a template cookie like "<s" is typed indented on a line, the
amount of white space before the cookie is applied to each new line in
the template.
Carsten Dominik 16 vuotta sitten
vanhempi
commit
3089eb6150
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5 2
      lisp/org.el

+ 5 - 2
lisp/org.el

@@ -9010,13 +9010,14 @@ expands them."
 (defun org-complete-expand-structure-template (start cell)
   "Expand a structure template."
   (let* ((musep (org-bound-and-true-p org-mtags-prefer-muse-templates))
-	 (rpl (nth (if musep 2 1) cell)))
+	 (rpl (nth (if musep 2 1) cell))
+	 (ind ""))
     (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)))
+	(setq ind (buffer-substring (point-at-bol) (point))))
        (t (newline))))
     (setq start (point))
     (if (string-match "%file" rpl)
@@ -9027,6 +9028,8 @@ expands them."
 		      (abbreviate-file-name (read-file-name "Include file: ")))
 		    "\"")
 		   t t rpl)))
+    (setq rpl (mapconcat 'identity (split-string rpl "\n")
+			 (concat "\n" ind)))
     (insert rpl)
     (if (re-search-backward "\\?" start t) (delete-char 1))))