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

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

[elpa] externals/org d2ce1c6ec1: lisp/ox-texinfo.el: Fix @menu in headli


From: ELPA Syncer
Subject: [elpa] externals/org d2ce1c6ec1: lisp/ox-texinfo.el: Fix @menu in headlines without contents
Date: Sat, 16 Dec 2023 09:58:15 -0500 (EST)

branch: externals/org
commit d2ce1c6ec1b52fcf03f08103f18f228763eae88a
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    lisp/ox-texinfo.el: Fix @menu in headlines without contents
    
    * lisp/ox-texinfo.el (org-texinfo--normalize-headlines): Do not rely
    upon undocumented implementation side-effects in `org-element-create'
    that have been changed.
    
    *
    testing/lisp/test-ox-texinfo.el (test-ox-texinfo/normalize-headlines):
    New test.
    
    Reported-by: Jonas Bernoulli <jonas@bernoul.li>
    Link: https://orgmode.org/list/87zfybnqwf.fsf@bernoul.li
---
 lisp/ox-texinfo.el              |  4 +++-
 testing/lisp/test-ox-texinfo.el | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index b8d95c9343..f99a3e036b 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -503,7 +503,9 @@ Return new tree."
          (let ((first (org-element-map contents '(headline section)
                         #'identity info t)))
            (unless (org-element-type-p first 'section)
-              (org-element-create 'section nil contents))))))
+              (apply #'org-element-set-contents
+                     hl
+                     (org-element-create 'section `(:parent ,hl)) 
contents))))))
     info)
   tree)
 
diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el
index 38395500df..f69b2ad6da 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -324,5 +324,26 @@
         nil nil nil nil nil
         #'texinfo-mode)))))
 
+
+;;; Filters
+
+(ert-deftest test-ox-texinfo/normalize-headlines ()
+  "Test adding empty sections to headlines without one."
+  (org-test-with-temp-text
+   "* only subsections, no direct content
+** sub 1
+body
+** sub 2
+body
+"
+   (let ((tree (org-element-parse-buffer)))
+     (setq tree (org-texinfo--normalize-headlines tree nil nil))
+     (let* ((first-heading (car (org-element-contents tree)))
+            (section (car (org-element-contents first-heading))))
+       (should (org-element-type-p first-heading 'headline))
+       (should (org-element-type-p section 'section))
+       (should-not (org-element-contents section))
+       (should (eq first-heading (org-element-parent section)))))))
+
 (provide 'test-ox-texinfo)
 ;;; test-ox-texinfo.el end here



reply via email to

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