1

I'm new to Emacs and I am trying to write an elisp script to automate the org-mode export for GitLab CI. The idea is that on the worker I simply run emacs --batch --no-init-file --load build.el --funcall org-publish-all to export my org project.

Since I use the :ignore: tag I need the (ox-extras-activate '(ignore-headlines)) line in my build.el. This obviously reports Symbol’s function definition is void: ox-extras-activate, but with (ox-extra is part of org-plus-contrib):

(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("org-plus-contrib" . "https://orgmode.org/elpa/") t)
(package-refresh-contents)

(require 'org)
(require 'ox-extra)

(ox-extras-activate '(ignore-headlines))

I got this error: Cannot open load file: File o directory non esistente, ox-extra.

I tried also with

(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("org-plus-contrib" . "https://orgmode.org/elpa/") t)
(package-refresh-contents)

(package-install 'org)
(package-install 'ox-extra)

(require 'org)
(require 'ox-extra)

(ox-extras-activate '(ignore-headlines))

which causes Package ‘ox-extra-’ is unavailable.

So I cannot find a way to setup ox-extra.

Full build.el:

;; build.el --- Build orgmode book

;;; Commentary:
;; This script will export the book

;;; Code:

(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("org-plus-contrib" . "https://orgmode.org/elpa/") t)
(package-refresh-contents)

(package-install 'org)
(package-install 'ox-extra)

(require 'org)
(require 'ox-extra)

(ox-extras-activate '(ignore-headlines))

(setq ; org-export-with-section-numbers nil
      org-export-with-smart-quotes t
      ; org-export-with-toc nil
      )

;; Minted
(setq org-export-latex-listings 'minted
      org-latex-packages-alist '(("" "minted"))
      org-latex-minted-options
      '(("autogobble=true") ("breaklines=true"))
      org-latex-pdf-process
      (mapcar
       (lambda (s)
         (replace-regexp-in-string "%latex " "%latex -shell-escape " s))
       org-latex-pdf-process))
  
;; Prepare to export
(setq org-html-divs '((preamble "header" "top")
                      (content "main" "content")
                      (postamble "footer" "postamble"))
      org-html-container-element "section"
      org-html-metadata-timestamp-format "%d/%m/%Y"
      org-html-checkbox-type 'html
      org-html-html5-fancy t
      ; org-html-validation-link nil
      org-html-doctype "html5")

(defvar site-attachments
  (regexp-opt '("jpg" "jpeg" "gif" "png" "svg"
                "ico" "cur" "css" "js" "woff" "woff2" "html" 
                ; "pdf"
                ))
  "File types that are published as static files.")

(setq
 common (list
         :base-directory "."
         :base-extension "org"
         :recursive nil
         :exclude (regexp-opt '("README" "LICENSE"))
         )
 )


;; Export
(setq org-publish-project-alist
      (list
       (append '("latex-org") common (list
                                      :publishing-function '(org-latex-export-to-pdf)
                                      :publishing-directory "."
                                      ))
       (append '("html-org") common (list
                                     :publishing-function '(org-html-export-to-html)
                                     :publishing-directory "./public"
                                     ;; :auto-sitemap t
                                     ;; :sitemap-filename "index.org"
                                     ;; :sitemap-file-entry-format "%d *%t*"
                                     ;; :html-head-extra "<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\"/>"
                                     ;; :sitemap-style 'list
                                     ;; :sitemap-sort-files 'anti-chronologically
                                     ))
       (list "site-static"
             :base-directory "."
             :exclude "public/"
             :base-extension site-attachments
             :publishing-directory "./public"
             :publishing-function 'org-publish-attachment
             :recursive t)
       (list "site" :components '("html-org" "site-static"))
       ))

(add-to-list 'org-latex-classes
             '("elegantbook"
               "\\documentclass{elegantbook}"
               ("\\part{%s}" . "\\part*{%s}")
               ("\\chapter{%s}" . "\\chapter*{%s}")
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))

(provide 'build)
;;; build.el ends here
3
  • 1
    I am not sure how this all works, but you probably have to (package-install 'org-contrib) (it is separate from org). Aug 11, 2021 at 7:41
  • Package ‘org-contrib-’ is unavailable, but now that you tell me I tried also with (package-install 'org-plus-contrib) and finally it works! Thank you very much
    – DPD-
    Aug 11, 2021 at 7:45
  • 1
    emacs.stackexchange.com/tags/elisp/info
    – Drew
    Aug 11, 2021 at 21:49

1 Answer 1

1

As pointed out by @dalanicolai the solution was simply to install org-plus-contrib instead of ox-extra:

(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("org-plus-contrib" . "https://orgmode.org/elpa/") t)
(package-refresh-contents)

(package-install 'org)
(package-install 'org-plus-contrib)

(require 'org)
(require 'ox-extra)

(ox-extras-activate '(ignore-headlines))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.