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

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

[elpa] externals/org 3a291b0 2/5: ox-publish.el: Add `org-html-publish-t


From: ELPA Syncer
Subject: [elpa] externals/org 3a291b0 2/5: ox-publish.el: Add `org-html-publish-to-html' as the default publishing function
Date: Wed, 29 Sep 2021 03:57:19 -0400 (EDT)

branch: externals/org
commit 3a291b0f0ecec5881ee79b75ee3176ee771eccc5
Author: Yasushi SHOJI <yasushi.shoji@gmail.com>
Commit: Bastien <bzg@gnu.org>

    ox-publish.el: Add `org-html-publish-to-html' as the default publishing 
function
    
    * lisp/org-macs.el (org-plist-delete-all): New function.
    
    * lisp/ox-publish.el (org-publish-file): Add
    `org-html-publish-to-html' as the default publishing function.
    
    * testing/lisp/test-ox-publish.el (org-test-publish): Use
    `org-plist-delete-all' to remove properties from the plist.
    
    Reported-by: Christopher W. Ryan
    See 
<https://list.orgmode.org/CAELBRWLgV-s6SGX=cevtN7iW8htwiLezR469T-cGMWE_6iX1+A@mail.gmail.com>
---
 lisp/org-macs.el                |  5 +++++
 lisp/ox-publish.el              |  3 ++-
 testing/lisp/test-ox-publish.el | 36 +++++++++++++++++++++++++++---------
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index bf1340b..231e29d 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -538,6 +538,11 @@ that may remove elements by altering the list structure."
     (setq list (delete (pop elts) list)))
   list)
 
+(defun org-plist-delete-all (plist props)
+  "Delete all elements in PROPS from PLIST."
+  (dolist (e props plist)
+    (setq plist (org-plist-delete plist e))))
+
 (defun org-plist-delete (plist property)
   "Delete PROPERTY from PLIST.
 This is in contrast to merely setting it to 0."
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index c25dd54..99b1dca 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -617,7 +617,8 @@ files, when entire projects are published (see
                          (abbreviate-file-name filename))))
         (project-plist (cdr project))
         (publishing-function
-         (pcase (org-publish-property :publishing-function project)
+         (pcase (org-publish-property :publishing-function project
+                                       'org-html-publish-to-html)
            (`nil (user-error "No publishing function chosen"))
            ((and f (pred listp)) f)
            (f (list f))))
diff --git a/testing/lisp/test-ox-publish.el b/testing/lisp/test-ox-publish.el
index 3503174..18e6f5e 100644
--- a/testing/lisp/test-ox-publish.el
+++ b/testing/lisp/test-ox-publish.el
@@ -22,12 +22,16 @@
 
 ;;; Helper functions
 
-(defun org-test-publish (properties handler)
+(defun org-test-publish (properties handler &optional remove-prop)
   "Publish a project defined by PROPERTIES.
 Call HANDLER with the publishing directory as its sole argument.
 Unless set otherwise in PROPERTIES, `:base-directory' is set to
 \"examples/pub/\" sub-directory from test directory and
-`:publishing-function' is set to `org-publish-attachment'."
+`:publishing-function' is set to `org-publish-attachment'.
+Because `org-publish-property' uses `plist-member' to check the
+existence of a property, a property with a value nil is different
+from a non-existing property.  Properties in REMOVE-PROP will be
+removed from the final plist."
   (declare (indent 1))
   (let* ((org-publish-use-timestamps-flag nil)
         (org-publish-cache nil)
@@ -35,13 +39,15 @@ Unless set otherwise in PROPERTIES, `:base-directory' is 
set to
         (pub-dir (make-temp-file "org-test" t))
         (org-publish-timestamp-directory
          (expand-file-name ".org-timestamps/" pub-dir))
+         (props (org-plist-delete-all
+                 (org-combine-plists
+                  `(:base-directory ,base-dir
+                    :publishing-function org-publish-attachment)
+                  properties
+                  `(:publishing-directory ,pub-dir))
+                 remove-prop))
         (project
-         `("test" ,@(org-combine-plists
-                     `(:base-directory
-                       ,base-dir
-                       :publishing-function org-publish-attachment)
-                     properties
-                     `(:publishing-directory ,pub-dir)))))
+         `("test" ,@props)))
     (unwind-protect
        (progn
          (org-publish-projects (list project))
@@ -92,7 +98,19 @@ Unless set otherwise in PROPERTIES, `:base-directory' is set 
to
            (lambda (dir)
              (remove ".org-timestamps"
                      (cl-remove-if #'file-directory-p
-                                   (directory-files dir))))))))
+                                   (directory-files dir)))))))
+
+  ;; Check the default trasformation function,
+  ;; org-html-publish-to-html. Because org-test-publish uses
+  ;; org-publish-attachment by default, we must not just override with
+  ;; nil but tell it to remove the :publishing-function from the list.
+  (should
+   (let ((func (lambda (dir)
+                 (with-temp-buffer
+                   (insert-file-contents (expand-file-name "a.html" dir))
+                   (buffer-string)))))
+    (equal (org-test-publish nil func '(:publishing-function))
+           (org-test-publish '(:publishing-function org-html-publish-to-html) 
func)))))
 
 
 ;;; Site-map



reply via email to

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