From 99876048ed871ce6ff2929dc7c763d7c403d1d71 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 6 Apr 2018 14:10:48 +0200 Subject: [PATCH] org: adjust to org-mode 9.1 This is needed so that SVG files are included as an rather than as an , 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. --- HACKING | 4 ++ doc/Makefile.am | 2 +- doc/org/.dir-locals.el.in | 3 -- doc/org/init.el.in | 74 ++++++++++++++++++++++--------- doc/org/spot.css | 1 + elisp/Makefile.am | 4 +- elisp/ob-dot.el | 91 --------------------------------------- 7 files changed, 62 insertions(+), 117 deletions(-) delete mode 100644 elisp/ob-dot.el diff --git a/HACKING b/HACKING index f70ce9bfa..4d0265ea8 100644 --- a/HACKING +++ b/HACKING @@ -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 diff --git a/doc/Makefile.am b/doc/Makefile.am index 1175aa847..b96c66542 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -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 diff --git a/doc/org/.dir-locals.el.in b/doc/org/.dir-locals.el.in index 4b1f6327c..1169e0855 100644 --- a/doc/org/.dir-locals.el.in +++ b/doc/org/.dir-locals.el.in @@ -55,10 +55,7 @@ :auto-sitemap t :sitemap-title "Sitemap for Spot" :publishing-function org-publish-org-to-html - ; Org 8 :html-head "\n" - ; Org 7 - :style "\n" :auto-preamble t) ("spot-static" :base-directory "." diff --git a/doc/org/init.el.in b/doc/org/init.el.in index 10714af1e..e9b6fac2c 100644 --- a/doc/org/init.el.in +++ b/doc/org/init.el.in @@ -1,15 +1,44 @@ -(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 "\n" - ; Org 7 - :style "\n" :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)) diff --git a/doc/org/spot.css b/doc/org/spot.css index e6affbb35..53828127d 100644 --- a/doc/org/spot.css +++ b/doc/org/spot.css @@ -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} diff --git a/elisp/Makefile.am b/elisp/Makefile.am index 93d720a5f..efdc604f5 100644 --- a/elisp/Makefile.am +++ b/elisp/Makefile.am @@ -1,5 +1,5 @@ ## -*- 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 . -EXTRA_DIST = hoa-mode.el ob-dot.el +EXTRA_DIST = hoa-mode.el GIT = https://gitlab.lrde.epita.fr/spot/emacs-modes/raw/master/ diff --git a/elisp/ob-dot.el b/elisp/ob-dot.el deleted file mode 100644 index e2e885788..000000000 --- a/elisp/ob-dot.el +++ /dev/null @@ -1,91 +0,0 @@ -;;; 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 . - -;;; 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