Commit 99876048 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

org: adjust to org-mode 9.1

This is needed so that SVG files are included as an <object...> rather
than as an <img...>, which in turn is needed to ensure SVG tooltips
will work.  We do not explicitly require org-mode 9.1, but we install
it if it is not present.

* HACKING: Mention the requirement.
* doc/org/.dir-locals.el.in, doc/org/init.el.in, doc/org/spot.css:
Adjust to org-mode 9.1.
* doc/Makefile.am: Run emacs with the site-lisp libraries, in
case it contains a more recent org-mode.
* elisp/ob-dot.el: Delete, this was a work around older versions.
* elisp/Makefile.am: Adjust.
parent 309eb0bb
......@@ -27,6 +27,10 @@ since the generated files they produce are distributed.)
GNU Flex (the version seems to matters, we used 2.5.35)
GNU Bison >= 3.0
GNU Emacs (preferably >= 24 but it may work with older versions)
org-mode >= 9.1 (the version that comes bundled with your emacs
version is likely out-of-date; but distribution often have
a separate and more recent org-mode package, or you can
simply upgrade from ELPA).
Groff (a.k.a. GNU troff) >= 1.20
SWIG >= 3.0 (for its better C++11/C++14 support)
Doxygen >= 1.4.0
......
......@@ -49,7 +49,7 @@ org: $(PICTURES_EXTRA)
cd $(top_builddir) && $(MAKE) doc/org/init.el
rm -rf $(srcdir)/userdoc $(builddir)/org/org.errors
$(MAKE) org-man org/plantuml.jar
$(EMACS) --batch -Q -l org/init.el
$(EMACS) --batch -q -l org/init.el
if test -s $(builddir)/org/org.errors; then \
cat $(builddir)/org/org.errors; exit 1; \
else :; fi
......
......@@ -55,10 +55,7 @@
:auto-sitemap t
:sitemap-title "Sitemap for Spot"
:publishing-function org-publish-org-to-html
; Org 8
:html-head "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
; Org 7
:style "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
:auto-preamble t)
("spot-static"
:base-directory "."
......
(setq load-path (append '("@abs_top_srcdir@/elisp/" ; for hoa-mode.el
;; htmlize is not always in the load-path.
;; On Debian it can be found here.
"/usr/share/emacs/site-lisp/emacs-goodies-el")
(setq load-path (append '("@abs_top_srcdir@/elisp/") ; for hoa-mode.el
load-path))
(or (require 'org-publish nil t) ; Org 7
(require 'ox-publish)) ; Org 8
(require 'org-install)
(setq debug-on-error t)
(package-initialize)
(require 'cl)
(setq features-before features)
(require 'org-version)
(print (org-version nil t t))
(print (concat "Org " org-version))
; The Org version that ships with emacs is usually too old.
(when (version< org-version "9.1")
(warn "Org-mode is too old; attempting to download a more recent version")
;; we need to unload any bits of org that were loaded before calling
;; install package, otherwise the byte code might mix the two versions.
(dolist (feature (set-difference features features-before))
(when (and (featurep feature)
(let ((feature-name (symbol-name feature)))
(or (string-prefix-p "org" feature-name)
(string-prefix-p "ob" feature-name))))
(message "unloading feature %s" feature)
(unload-feature feature t)))
;; install org-plus-contrib, not org, as the former includes htmlize
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-refresh-contents)
(let ((org-p-c (cadr (assq 'org-plus-contrib package-archive-contents))))
(package-install org-p-c)))
(unless (require 'htmlize nil t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-refresh-contents)
(let ((htmlize (cadr (assq 'htmlize package-archive-contents))))
(package-install htmlize)))
(require 'ox-publish)
(require 'org-install)
(require 'hoa-mode)
(print (concat "Org " (org-version)))
(setq org-export-htmlize-output-type 'css)
(setq org-html-htmlize-output-type 'css)
; the .org-timestamp directory does not always exist, is not always
......@@ -29,6 +58,9 @@
(setq org-confirm-babel-evaluate nil)
(setq org-plantuml-jar-path "@abs_top_builddir@/doc/org/plantuml.jar")
(setq org-babel-temporary-directory "@abs_top_builddir@/doc/org/tmp")
;;; the directory might already exist from a previously aborted run.
(if (file-directory-p org-babel-temporary-directory)
(delete-directory org-babel-temporary-directory t))
(make-directory org-babel-temporary-directory t)
(setq org-babel-python-command "@PYTHON@")
(setq org-babel-C++-compiler "./g++wrap")
......@@ -37,9 +69,8 @@
(setq org-babel-default-header-args:plantuml
'((:results . "file")
(:exports . "results")
;; prevent the plantuml logo to annoying appear on top of
;; whatever you are doing when the project compiles in the
;; background.
;; Prevent the plantuml logo to appear on top of whatever you
;; are doing when the project compiles in the background.
(:java . "-Djava.awt.headless=true")))
(setenv "PATH"
......@@ -66,8 +97,14 @@
(setq org-export-html-postamble nil)
(defun spot-publish-sitemap (title list)
"Same as org-publish-sitemap-default except it adds the SETUPFILE."
(concat "#+TITLE: " title
"\n#+SETUPFILE: setup.org\n#+HTML_LINK_UP: index.html\n\n"
(org-list-to-org list)))
(setq org-publish-project-alist
`(("spot-html"
'(("spot-html"
:base-directory "@abs_top_srcdir@/doc/org/"
:base-extension "org"
:publishing-directory "@abs_top_srcdir@/doc/userdoc/"
......@@ -75,13 +112,9 @@
:exclude "setup.org"
:auto-sitemap t
:sitemap-title "Sitemap for Spot"
:publishing-function
,(if (require 'org-publish nil t) 'org-publish-org-to-html ; Org 7
'org-html-publish-to-html) ; Org 8
; Org 8
:sitemap-function spot-publish-sitemap
:publishing-function org-html-publish-to-html
:html-head "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
; Org 7
:style "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
:auto-preamble t)
("spot-static"
:base-directory "@abs_top_srcdir@/doc/org/"
......@@ -94,5 +127,6 @@
(org-publish-all t)
;;; org-babel-remove-temporary-directory does not correctly remove
;;; nested directories and we have some files in tmp/.libs/ because of
;;; libtool. So let us clean that ourselves.
(delete-directory org-babel-temporary-directory t)
;;; libtool. So we have to clean that ourselves.
(if (file-directory-p org-babel-temporary-directory)
(delete-directory org-babel-temporary-directory t))
......@@ -39,6 +39,7 @@ thead tr {background: #ffe35e;}
#content tbody:nth-child(odd) tr:nth-child(odd) {background: #fff7cf;}
#content tbody:nth-child(even) tr:nth-child(even) {background: #fff3bc;}
#content tbody:nth-child(even) tr:nth-child(odd) {background: #fffbe0;}
.org-svg {max-width:100%;width:auto;}
.org-keyword{font-weight:bold}
.org-builtin{font-weight:bold}
.org-preprocessor{font-weight:bold}
......
## -*- coding: utf-8 -*-
## Copyright (C) 2015, 2016, 2017 Laboratoire de Recherche et Développement
## Copyright (C) 2015, 2016, 2017, 2018 Laboratoire de Recherche et Développement
## de l'Epita (LRDE).
##
## This file is part of Spot, a model checking library.
......@@ -17,7 +17,7 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = hoa-mode.el ob-dot.el
EXTRA_DIST = hoa-mode.el
GIT = https://gitlab.lrde.epita.fr/spot/emacs-modes/raw/master/
......
;;; ob-dot.el --- org-babel functions for dot evaluation
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Org-Babel support for evaluating dot source code.
;;
;; For information on dot see http://www.graphviz.org/
;;
;; This differs from most standard languages in that
;;
;; 1) there is no such thing as a "session" in dot
;;
;; 2) we are generally only going to return results of type "file"
;;
;; 3) we are adding the "file" and "cmdline" header arguments
;;
;; 4) there are no variables (at least for now)
;;; Code:
(require 'ob)
(defvar org-babel-default-header-args:dot
'((:results . "file") (:exports . "results"))
"Default arguments to use when evaluating a dot source block.")
(defun org-babel-expand-body:dot (body params)
"Expand BODY according to PARAMS, return the expanded body."
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
(mapc
(lambda (pair)
(let ((name (symbol-name (car pair)))
(value (cdr pair)))
(setq body
(replace-regexp-in-string
(concat "$" (regexp-quote name))
(if (stringp value) value (format "%S" value))
body
t
t))))
vars)
body))
(defun org-babel-execute:dot (body params)
"Execute a block of Dot code with org-babel.
This function is called by `org-babel-execute-src-block'."
(let* ((result-params (cdr (assoc :result-params params)))
(out-file (cdr (or (assoc :file params)
(error "You need to specify a :file parameter"))))
(cmdline (or (cdr (assoc :cmdline params))
(format "-T%s" (file-name-extension out-file))))
(cmd (or (cdr (assoc :cmd params)) "dot"))
(in-file (org-babel-temp-file "dot-")))
(with-temp-file in-file
(insert (org-babel-expand-body:dot body params)))
(org-babel-eval
(concat cmd
" " (org-babel-process-file-name in-file)
" " cmdline
" -o " (org-babel-process-file-name out-file)) "")
nil)) ;; signal that output has already been written to file
(defun org-babel-prep-session:dot (session params)
"Return an error because Dot does not support sessions."
(error "Dot does not support sessions"))
(provide 'ob-dot)
;;; ob-dot.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment