branch: externals/org
commit 0cbf8817f97e1d6dfd52d54c91758792d92a3563
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-export-async-start: Drop text properties from exported text
    
    * lisp/org-element.el (org-element--generate-copy-script):
    New keyword argument to drop text properties from buffer string when
    copying.
    * lisp/ox.el (org-export-async-start): Strip text properties from
    script generated for async Emacs call.  Text properties are not
    required there and may contain unreadable Elisp objects.
    
    Reported-by: Benjamin McMillan <mcmilla...@gmail.com>
    Link: 
https://orgmode.org/list/calo8a5u1u7qlo-zfu78zjqsm6bn_tvmxl-ye_6gqbmd+tsa...@mail.gmail.com
---
 lisp/org-element.el | 25 ++++++++++++++-----------
 lisp/ox.el          |  5 ++++-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 5a7435581a..8e17af8cf6 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -533,13 +533,11 @@ created, all Org related local variables not in this list 
are copied
 to the new buffer.  Variables with an unreadable value are also
 ignored.")
 
-(cl-defun org-element--generate-copy-script (buffer
-                                             &key
-                                             copy-unreadable
-                                             drop-visibility
-                                             drop-narrowing
-                                             drop-contents
-                                             drop-locals)
+(cl-defun org-element--generate-copy-script
+    (buffer
+     &key
+     copy-unreadable drop-visibility drop-narrowing
+     drop-contents drop-text-properties drop-locals)
   "Generate a function duplicating BUFFER.
 
 The copy will preserve local variables, visibility, contents and
@@ -549,9 +547,10 @@ BUFFER, contents will be narrowed to that region instead.
 When optional key COPY-UNREADABLE is non-nil, do not ensure that all
 the copied local variables will be readable in another Emacs session.
 
-When optional keys DROP-VISIBILITY, DROP-NARROWING, DROP-CONTENTS, or
-DROP-LOCALS are non-nil, do not preserve visibility, narrowing,
-contents, or local variables correspondingly.
+When optional keys DROP-VISIBILITY, DROP-NARROWING, DROP-CONTENTS,
+DROP-TEXT-PROPERTIES, or DROP-LOCALS are non-nil, do not preserve
+visibility, narrowing, contents, text properties of contents, or local
+variables correspondingly.
 
 The resulting function can be evaluated at a later time, from
 another buffer, effectively cloning the original buffer there.
@@ -560,7 +559,11 @@ The function assumes BUFFER's major mode is `org-mode'."
   (declare-function org-fold-core--update-buffer-folds "org-fold-core" ())
   (require 'org-fold-core)
   (with-current-buffer buffer
-    (let ((str (unless drop-contents (org-with-wide-buffer (buffer-string))))
+    (let ((str (unless drop-contents
+                 (org-with-wide-buffer
+                  (if drop-text-properties
+                      (substring-no-properties (buffer-string))
+                    (buffer-string)))))
           (narrowing
            (unless drop-narrowing
              (if (org-region-active-p)
diff --git a/lisp/ox.el b/lisp/ox.el
index 646d09b51e..7d44c3d702 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6701,7 +6701,10 @@ and `org-export-to-file' for more specialized functions."
   ;; buffer to a temporary file, as it may be too long for program
   ;; args in `start-process'.
   (with-temp-message "Initializing asynchronous export process"
-    (let ((copy-fun (org-element--generate-copy-script (current-buffer)))
+    (let ((copy-fun (org-element--generate-copy-script
+                     ;; Text properties may contain unreadable Elisp
+                     ;; objects. Avoid them.
+                     (current-buffer) :drop-text-properties t))
           (temp-file (make-temp-file "org-export-process")))
       (let ((coding-system-for-write 'emacs-internal))
         (write-region

Reply via email to