forked from tgbugs/orgstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
129 lines (99 loc) · 4.14 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
;;; init.el --- entry point -*- lexical-binding: t -*-
;;; Commentary:
;; minimal init to bootstrap orgmode
;; for compiling documentation in CI
;; adapted from scimax/init.el
(setq gc-cons-threshold 80000000)
(defconst working-dir (file-name-directory (or load-file-name (buffer-file-name)))
"Directory where this file is located")
(defcustom orgstrap-use-default-package-dir nil
"If not `nil' orgstrap uses the default package-user-dir
instead of creating one in the same folder as this init.el file")
(unless orgstrap-use-default-package-dir
(setq package-user-dir (expand-file-name "elpa" working-dir)))
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(add-to-list
'package-archives
(cons "melpa" (concat proto "://melpa.org/packages/")) t)
(add-to-list
'package-archives
(cons "org" (concat proto "://orgmode.org/elpa/")))
(when no-ssl
(setq package-check-signature nil)
(setq tls-program
;; Defaults:
'("gnutls-cli --insecure -p %p %h"
"gnutls-cli --insecure -p %p %h --protocols ssl3"
"openssl s_client -connect %h:%p -no_ssl2 -ign_eof")
;; '("gnutls-cli -p %p %h"
;; "openssl s_client -connect %h:%p -no_ssl2 -no_ssl3 -ign_eof")
))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
(add-to-list 'load-path working-dir)
(set-language-environment "UTF-8")
;;; bootstrap --- install use-package
(unless package--initialized
(package-initialize))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
;;; bootstrap ends here
;;; packages.el --- minimal packages needed for html export
(setq use-package-always-ensure t)
;; * org-mode
(use-package org-plus-contrib
:mode ("\\.org\\'" . org-mode))
(use-package htmlize)
;;; packages ends here
;;; batch mode color fixes
;; this one was a real adventure, found `display-color-cells' and
;; `display-color-p' and a couple other things while hunting down
;; `min-colors' in `defface' and finally landed on this
;; it really seems like this should be the default behavior in emacs
(defun noninteractive-face-spec-set-match-display (command &rest args)
"adivse native `face-spec-set-match-display' when `noninteractive'is true
(i.e., in --batch mode) so that `org-src-fontify-natively' will work"
t)
(when noninteractive
(advice-add 'face-spec-set-match-display
:around 'noninteractive-face-spec-set-match-display))
;;; use additional packages
(defmacro use-packages (&rest names)
"enable multiple calls to `use-package' during bootstrap"
(cons 'progn (mapcar (lambda (name) `(use-package ,name)) names)))
;;; pipe functions
(defmacro defpipefun (name &rest body)
"define a new function for modifying things piped through std* == FUN!"
`(defun ,name ()
;; from https://joelmccracken.github.io/entries/reading-writing-data-in-emacs-batch-via-stdin-stdout/
;; NOTE writing a comile-org-forever doesn't seem to work because read-from-minibuffer cannot block
;; NOTE if you wrap emacs for launch in any way e.g. with emacs "${@}" & this script will fail
;; NOTE in emacs 25 the title of the buffer takes precedence for some reason?
(interactive)
(let ((to-be-inserted-into-buffer "")
this-read)
(while (setq this-read (ignore-errors
(read-from-minibuffer "")))
(setq to-be-inserted-into-buffer (concat to-be-inserted-into-buffer "\n" this-read)))
(with-temp-buffer
(insert to-be-inserted-into-buffer)
,@body
(princ (buffer-string))))))
(defpipefun compile-org-file
(org-mode)
(org-html-export-as-html))
(defpipefun align-tables-org-file
(org-mode)
(org-table-map-tables 'org-table-align))
(defpipefun align-tables-and-compile-org-file
(org-mode)
(org-table-map-tables 'org-table-align)
(org-html-export-as-html))
;;; init.el ends here