emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-transclusion 28737e1b5c 08/29: Need newline guarent


From: ELPA Syncer
Subject: [elpa] externals/org-transclusion 28737e1b5c 08/29: Need newline guarentee also in content-src-lines
Date: Mon, 8 May 2023 06:59:08 -0400 (EDT)

branch: externals/org-transclusion
commit 28737e1b5c7490c1fb1f0dcb3cf122eb3cc90c10
Author: Benjamin Cherry <Ben@devcarbon.com>
Commit: Benjamin Cherry <Ben@devcarbon.com>

    Need newline guarentee also in content-src-lines
---
 org-transclusion-src-lines.el |  2 +-
 org-transclusion.el           | 29 +++++++++++++++--------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/org-transclusion-src-lines.el b/org-transclusion-src-lines.el
index 4aec22daae..3bc7cc4e76 100644
--- a/org-transclusion-src-lines.el
+++ b/org-transclusion-src-lines.el
@@ -211,7 +211,7 @@ for the range works."
                           (format "#+begin_src %s" src-lang)
                           (when rest (format " %s" rest))
                           "\n"
-                          src-content
+                          (org-transclusion--ensure-newline src-content)
                           "#+end_src\n")))))
     ;; Return the payload either modified or unmodified
     payload))
diff --git a/org-transclusion.el b/org-transclusion.el
index 5f4c3acbed..ed6cf3ba5c 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -949,6 +949,10 @@ Return nil if not found."
 ;;-----------------------------------------------------------------------------
 ;;;; Functions for inserting content
 
+(defun org-transclusion--ensure-newline (str)
+  (when (not (string-suffix-p "\n" str))
+    (concat str "\n")))
+
 (defun org-transclusion-content-insert (keyword-values type content sbuf sbeg 
send copy)
   "Insert CONTENT at point and put source overlay in SBUF.
 Return t when successful.
@@ -978,20 +982,17 @@ based on the following arguments:
          (end-mkr)
          (ov-src (text-clone-make-overlay sbeg send sbuf)) ;; source-buffer 
overlay
          (tc-pair ov-src)
-         (ensure-newline (lambda (str)
-                           (when (not (string-suffix-p "\n" str)))
-                           (concat str "\n")))
-         (content (funcall ensure-newline content)))
+         (content (org-transclusion--ensure-newline content)))
     (when (org-transclusion-type-is-org type)
-        (with-temp-buffer
-          ;; This temp buffer needs to be in Org Mode
-          ;; Otherwise, subtree won't be recognized as a Org subtree
-          (delay-mode-hooks (org-mode))
-          (insert content)
-          (org-with-point-at 1
-            (let* ((to-level (plist-get keyword-values :level))
-                   (level (org-transclusion-content-highest-org-headline))
-                   (diff (when (and level to-level) (- level to-level))))
+      (with-temp-buffer
+        ;; This temp buffer needs to be in Org Mode
+        ;; Otherwise, subtree won't be recognized as a Org subtree
+        (delay-mode-hooks (org-mode))
+        (insert content)
+        (org-with-point-at 1
+          (let* ((to-level (plist-get keyword-values :level))
+                 (level (org-transclusion-content-highest-org-headline))
+                 (diff (when (and level to-level) (- level to-level))))
             (when diff
               (cond ((< diff 0) ; demote
                      (org-map-entries (lambda ()
@@ -1001,7 +1002,7 @@ based on the following arguments:
                      (org-map-entries (lambda ()
                                         (dotimes (_ diff)
                                           (org-do-promote))))))))
-            (setq content (buffer-string)))))
+          (setq content (buffer-string)))))
     (insert
      (run-hook-with-args-until-success
       'org-transclusion-content-format-functions



reply via email to

[Prev in Thread] Current Thread [Next in Thread]