فهرست منبع

:padline insertion aware of placement in file

* lisp/ob-tangle.el (org-babel-spec-to-string): Remove padline
  handling from here as there is insufficient information on context.
  (org-babel-tangle): Moved padline handling here where we can test
  for placement in the file.
Eric Schulte 11 سال پیش
والد
کامیت
ae21350aaa
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 4 2
      lisp/ob-tangle.el

+ 4 - 2
lisp/ob-tangle.el

@@ -243,6 +243,10 @@ used to limit the exported source code blocks by language."
 			    (if (file-exists-p file-name)
 				(insert-file-contents file-name))
 			    (goto-char (point-max))
+			    ;; Handle :padlines unless first line in file
+			    (unless (or (string= "no" (cdr (assoc :padline (nth 4 spec))))
+					(= (point) (point-min)))
+			      (insert "\n"))
 			    (insert content)
 			    (write-region nil nil file-name))))
 		      ;; if files contain she-bangs, then make the executable
@@ -307,7 +311,6 @@ that the appropriate major-mode is set.  SPEC has the form:
 	 (body (nth 5 spec))
 	 (comment (nth 6 spec))
 	 (comments (cdr (assoc :comments (nth 4 spec))))
-	 (padline (not (string= "no" (cdr (assoc :padline (nth 4 spec))))))
 	 (link-p (or (string= comments "both") (string= comments "link")
 		     (string= comments "yes") (string= comments "noweb")))
 	 (link-data (mapcar (lambda (el)
@@ -327,7 +330,6 @@ that the appropriate major-mode is set.  SPEC has the form:
       (funcall
        insert-comment
        (org-fill-template org-babel-tangle-comment-format-beg link-data)))
-    (when padline (insert "\n"))
     (insert
      (format
       "%s\n"