init.el.in 7.7 KB
Newer Older
1
(setq load-path (append '("@abs_top_srcdir@/elisp/") ; for hoa-mode.el
2
			load-path))
3
4
5

(setq debug-on-error t)

6
7
8
9
10
11
12
13
14
;;; Some combination of GNU TLS and Emacs fail to retrieve archive
;;; contents over https.
;;; https://www.reddit.com/r/emacs/comments/cdf48c/failed_to_download_gnu_archive/
;;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341
(if (and (version< emacs-version "26.3") (>= libgnutls-version 30600))
    (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
; work around obsolete ELPA signatures :-(
(setq package-check-signature 'nil)

15
16
17
18
(package-initialize)
(require 'cl)
(setq features-before features)

Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
19
(require 'org-version)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(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)))

41
42
43
44
45
46
47
48
49
50
51
(let ((have-htmlize (require 'htmlize nil t))
      (have-ess (require 'ess nil t)))
  (unless (and have-htmlize have-ess)
    (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
    (package-refresh-contents)
    (unless have-htmlize
      (let ((htmlize (cadr (assq 'htmlize package-archive-contents))))
        (package-install htmlize)))
    (unless have-ess
      (let ((ess (cadr (assq 'ess package-archive-contents))))
        (package-install ess)))))
52
53
54

(require 'ox-publish)
(require 'org-install)
55
(require 'hoa-mode)
56

57
58
59
60
; See https://github.com/emacs-ess/ESS/issues/1052
(setq ess-gen-proc-buffer-name-function 'ess-gen-proc-buffer-name:directory)
(setq ess-use-flymake nil)

61
(setq org-export-htmlize-output-type 'css)
62
(setq org-html-htmlize-output-type 'css)
63
64
65
; the .org-timestamp directory does not always exist, is not always
; created by org, and that causes issues on our buildfarm.
(setq org-publish-use-timestamps-flag nil)
66
67
68
;; The default value of writing to ~/.org-timestamps causes race
;; conditions when doing concurrent builds.
(setq org-publish-timestamp-directory "@abs_top_builddir@/.org-timestamps/")
69

70
71
72
;; Prevent tabs from being inserted when org-mode reindent some code.
(setq-default indent-tabs-mode nil)

73
74
(org-babel-do-load-languages
 'org-babel-load-languages
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
75
 `((,(if (version< org-version "8.3") 'sh 'shell) . t)
76
   (dot . t)
77
   (python . t)
78
   (plantuml . t)
79
   (R . t)
80
   (C . t)))
81
(setq org-confirm-babel-evaluate nil)
82
(setq org-plantuml-jar-path "@abs_top_builddir@/doc/org/plantuml.jar")
83
(setq org-babel-temporary-directory "@abs_top_builddir@/doc/org/tmp")
84
85
86
;;; 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))
87
(make-directory org-babel-temporary-directory t)
88
(setq org-babel-python-command "@PYTHON@")
89
(setq org-babel-C++-compiler "./g++wrap")
90
(setq shell-file-name "@SHELL@")
91
(setq ess-ask-for-ess-directory nil)
92

93
94
95
(setq org-babel-default-header-args:plantuml
      '((:results . "file")
        (:exports . "results")
96
97
        ;; Prevent the plantuml logo to appear on top of whatever you
        ;; are doing when the project compiles in the background.
98
        (:java . "-Djava.awt.headless=true")))
99

100
(setenv "PATH"
101
	(concat "@abs_top_builddir@/bin" path-separator (getenv "PATH")))
102
(setenv "SPOT_UNINSTALLED" "1")
103
(setenv "PYTHONPATH"
104
105
106
107
108
	(concat "@abs_top_builddir@/python/.libs:"
		"@abs_top_builddir@/python:"
		"@abs_top_srcdir@/python:"
		"@abs_top_builddir@/python/spot/.libs:"
		"@abs_top_builddir@/python/spot:"
109
		"@abs_top_builddir@/spot/ltsmin/.libs"
110
		"@abs_top_srcdir@/python/spot:"
111
112
		(getenv "PYTHONPATH")))
(setenv "DYLD_LIBRARY_PATH"
113
	(concat "@abs_top_builddir@/python/.libs:@abs_top_builddir@/spot/.libs:@abs_top_builddir@/buddy/src/.libs:"
114
		(getenv "DYLD_LIBRARY_PATH")))
115
(setenv "SPOT_DOTDEFAULT" "Brf(Lato)C(#ffffa0)")
116
(setenv "SPOT_DOTEXTRA" "node[fontsize=12] fontsize=12 stylesheet=\"spot.css\" edge[arrowhead=vee, arrowsize=.7, fontsize=12]")
117

118
119
120
121
122
(setq org-export-html-home/up-format
"<div id=\"org-div-home-and-up\" style=\"text-align:center;white-space:nowrap;\">
 <a accesskey=\"h\" href=\"%s\">UP</a> | <a accesskey=\"H\" href=\"%s\">HOME</a>
</div>")

123
(setq org-export-html-postamble nil)
124
125
(setq org-html-table-header-tags
      '("<th scope=\"%s\"%s><div><span>" . "</span></div></th>"))
126

Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
(defun spot-sitemap-format-entry (entry style project)
  "Export a sitemap entry in a why that we can order them meaningfully.
If file ENTRY has HTML_LINK_UP pointing to file up.html, and file
up.html points to index.html, then the result is:
      index.org/up.org/entry.org/ [[entry.org][TITLE]]"
  (let ((linkup (org-publish-find-property entry :html-link-up project 'html))
        (trail (concat entry "/ ")))
    (while (and linkup (string-match "^\\(.*\\)\.html$" linkup))
      (let ((match (concat (match-string 1 linkup) ".org")))
        (if (string= match entry)
            (setq linkup nil)
          (setq linkup (org-publish-find-property match :html-link-up
                                                  project 'html)
                trail (concat match "/" trail)))))
    (concat trail (org-publish-sitemap-default-entry entry style project))))

(defun spot-sitemap-reorder (entries)
  (sort entries (lambda (a b) (string< (car a) (car b)))))

(defun spot-publish-sitemap (title thelist)
  "Build Spot's sitemap.

  This is done by sorting all lines, and then replacing
  - index.org/up.org/entry.org/ [[entry.org][TITLE]]
  by
  - [[entry.org][TITLE]]
  but indented according to the number of 'fake directory' parts."
  (let ((body (org-list-to-org (cons 'unordered
                                 (spot-sitemap-reorder (cdr thelist))))))
    (while
        (let* ((res (replace-regexp-in-string "\\([:space:]*\\)- [^/[:space:]]+/" "  \\1- " body))
               (cmp (string= res body)))
          (setq body res)
          (not cmp)))
    (concat "#+TITLE: " title
            "\n#+SETUPFILE: setup.org\n#+HTML_LINK_UP: index.html\n\n"
            body)))
164

165
(setq org-publish-project-alist
166
      '(("spot-html"
167
168
169
170
	:base-directory "@abs_top_srcdir@/doc/org/"
	:base-extension "org"
	:publishing-directory "@abs_top_srcdir@/doc/userdoc/"
	:recursive t
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
171
172
173
	:exclude "setup.org"
	:auto-sitemap t
	:sitemap-title "Sitemap for Spot"
174
        :sitemap-function spot-publish-sitemap
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
175
        :sitemap-format-entry spot-sitemap-format-entry
176
	:publishing-function org-html-publish-to-html
177
	:html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
178
179
180
	:auto-preamble t)
       ("spot-static"
	:base-directory "@abs_top_srcdir@/doc/org/"
181
	:base-extension "css\\|js\\|png\\|svg\\|jpg\\|gif\\|pdf"
182
183
184
185
186
187
	:publishing-directory "@abs_top_srcdir@/doc/userdoc/"
	:recursive t
	:publishing-function org-publish-attachment)
       ("spot-all" :components ("spot-html" "spot-static"))))

(org-publish-all t)
188
189
;;; org-babel-remove-temporary-directory does not correctly remove
;;; nested directories and we have some files in tmp/.libs/ because of
190
191
192
;;; libtool.  So we have to clean that ourselves.
(if (file-directory-p org-babel-temporary-directory)
    (delete-directory org-babel-temporary-directory t))