set `custom-file' and load it
[~bandali/configs] / emacs / init.org
CommitLineData
35ea1ba4
AB
1#+title: =aminb='s Emacs Init file
2#+property: header-args :results silent :comments link :tangle ~/dotfiles/emacs/init.el
3
4* Intro
5
6TODO: description
7
8TODO: toc
9
10* Header
11
12** First line
13
14#+begin_src emacs-lisp :comments none
15;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t ; eval: (view-mode 1)-*-
16#+end_src
17
18Enable =view-mode=, which both makes the file read-only (as a reminder
19that =init.el= is an auto-generated file, not supposed to be edited),
20and provides some convenient key bindings for browsing through the
21file.
22
23** License
24
25#+begin_src emacs-lisp :comments none
26;; Copyright (C) 2018 Amin Bandali <amin@aminb.org>
27
28;; This program is free software: you can redistribute it and/or modify
29;; it under the terms of the GNU General Public License as published by
30;; the Free Software Foundation, either version 3 of the License, or
31;; (at your option) any later version.
32
33;; This program is distributed in the hope that it will be useful,
34;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36;; GNU General Public License for more details.
37
38;; You should have received a copy of the GNU General Public License
39;; along with this program. If not, see <https://www.gnu.org/licenses/>.
40#+end_src
41
42** Commentary
43
6089982a 44#+begin_src emacs-lisp :comments none
35ea1ba4
AB
45;;; Commentary:
46
47;; Emacs configuration of Amin Bandali, computer scientist and functional
48;; programmer.
49
50;; THIS FILE IS AUTO-GENERATED FROM `init.org'.
51#+end_src
52
53* Config
54
6089982a 55#+begin_src emacs-lisp :comments none
35ea1ba4
AB
56;;; Code:
57#+end_src
58
6089982a
AB
59** Startup time
60
61Measure and display startup time. Also, temporarily increase
62~gc-cons-threshhold~ during startup to reduce reduce garbage
63collection frequency. Taken from [[https://github.com/dieggsy/dotfiles/tree/3d95bc08033920e077855caf545a975eba52d28d/emacs.d#startup-time][here]].
64
65#+begin_src emacs-lisp
66(defconst aminb/emacs-start-time (current-time))
67(defconst aminb/gc-cons-threshold gc-cons-threshold)
68(defconst aminb/gc-cons-percentage gc-cons-percentage)
69(defvar aminb/file-name-handler-alist file-name-handler-alist)
70(setq gc-cons-threshold 400000000
71 gc-cons-percentage 0.6
72 file-name-handler-alist nil
73 ;; sidesteps a bug when profiling with esup
74 esup-child-profile-require-level 0)
75#+end_src
76
77Reset the variables back to default after init.
78
79#+begin_src emacs-lisp
80(add-hook
81 'after-init-hook
82 `(lambda ()
83 (setq gc-cons-threshold aminb/gc-cons-threshold
84 gc-cons-percentage aminb/gc-cons-percentage
85 file-name-handler-alist aminb/file-name-handler-alist)
86 (let ((elapsed (float-time (time-subtract (current-time)
87 aminb/emacs-start-time))))
88 (message "Loading %s...done (%.3fs) [after-init]"
89 ,load-file-name elapsed))))
90#+end_src
35ea1ba4 91
bab98ee5
AB
92** Custom file (=custom.el=)
93
94I'm not planning on using the custom file much, but even so, I
95definitely don't want it mixing with =init.el=. So, here, let's give
96it it's own file.
97
98#+begin_src emacs-lisp
99(setq custom-file (expand-file-name
100 "etc/custom.el"
101 user-emacs-directory))
102(load custom-file)
103#+end_src
104
105** Org
106
107#+begin_src emacs-lisp
108(setq org-src-tab-acts-natively t
109 org-src-preserve-indentation nil
110 org-edit-src-content-indentation 0)
111#+end_src
112
35ea1ba4
AB
113* Footer
114
115#+begin_src emacs-lisp :comments none
35ea1ba4
AB
116;;; init.el ends here
117#+end_src