forked from SystemCrafters/crafted-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
127 lines (102 loc) · 4.75 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
;;; init.el -*- lexical-binding: t; -*-
;; Profile emacs startup
(add-hook 'emacs-startup-hook
(lambda ()
(message "Crafted Emacs loaded in %s."
(emacs-init-time))))
;; Define customization group for Crafted Emacs.
(defgroup crafted '()
"A sensible starting point for hacking your own Emacs configuration."
:tag "Crafted Emacs"
:link '(url-link "https://github.com/SystemCrafters/crafted-emacs")
:group 'emacs)
(when (eq crafted-package-system 'package)
(crafted-package-initialize))
;; Add the modules folder to the load path
(add-to-list 'load-path (expand-file-name "modules/" user-emacs-directory))
;; Add the user's custom-modules to the top of the load-path
;; so any user custom-modules take precedence.
(when (file-directory-p (expand-file-name "custom-modules/" crafted-config-path))
(setq load-path
(append (let ((load-path (list))
(default-directory (expand-file-name "custom-modules/" crafted-config-path)))
(add-to-list 'load-path (expand-file-name "custom-modules/" crafted-config-path))
;;(normal-top-level-add-to-load-path '("."))
(normal-top-level-add-subdirs-to-load-path)
load-path)
load-path)))
;; Set default coding system (especially for Windows)
(set-default-coding-systems 'utf-8)
(customize-set-variable 'visible-bell 1) ; turn off beeps, make them flash!
(customize-set-variable 'large-file-warning-threshold 100000000) ;; change to ~100 MB
(defun crafted-ensure-package (package &optional args)
"Ensure that PACKAGE is installed on the system, either via
package.el or Guix depending on the value of
`crafted-prefer-guix-packages'."
(if crafted-prefer-guix-packages
(unless (featurep package)
(message "Package '%s' does not appear to be installed by Guix: " package))
(crafted-package-install-package package)))
;; Check the system used
(defconst ON-LINUX (eq system-type 'gnu/linux))
(defconst ON-MAC (eq system-type 'darwin))
(defconst ON-BSD (or ON-MAC (eq system-type 'berkeley-unix)))
(defconst ON-WINDOWS (memq system-type '(cygwin windows-nt ms-dos)))
;; Find the user configuration file
(defvar crafted-config-file (expand-file-name "config.el" crafted-config-path)
"The user's configuration file.")
;; Defines the user configuration var and etc folders
;; and ensure they exist.
(defvar crafted-config-etc-directory (expand-file-name "etc/" crafted-config-path)
"The user's configuration etc/ folder.")
(defvar crafted-config-var-directory (expand-file-name "var/" crafted-config-path)
"The user's configuration var/ folder.")
(mkdir crafted-config-etc-directory t)
(mkdir crafted-config-var-directory t)
;; Load the user configuration file if it exists
(when (file-exists-p crafted-config-file)
(load crafted-config-file nil 'nomessage))
;; When writing crafted-modules, insert header from skeleton
(auto-insert-mode)
(with-eval-after-load "autoinsert"
(define-auto-insert
(cons (concat (expand-file-name user-emacs-directory) "modules/crafted-.*\\.el")
"Crafted Emacs Lisp Skeleton")
'("Crafted Emacs Module Description: "
";;;; " (file-name-nondirectory (buffer-file-name)) " --- " str
(make-string (max 2 (- 80 (current-column) 27)) ?\s)
"-*- lexical-binding: t; -*-" '(setq lexical-binding t)
"
;; Copyright (C) " (format-time-string "%Y") "
;; SPDX-License-Identifier: MIT
;; Author: System Crafters Community
;;; Commentary:
;; " _ "
;;; Code:
(provide '"
(file-name-base (buffer-file-name))
")
;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")))
;; The file used by the Customization UI to store value-setting
;; forms in a customization file, rather than at the end of the
;; `init.el' file, is called `custom.el' in Crafted Emacs. The file
;; is loaded after this `init.el' file, and after the user `config.el'
;; file has been loaded. Any variable values set in the user
;; `config.el' will be overridden with the values set with the
;; Customization UI and saved in the custom file.
(customize-set-variable 'custom-file
(expand-file-name "custom.el" crafted-config-path))
;; The custom file will only be loaded if `crafted-load-custom-file'
;; is set to a non-nil value in the user's `config.el'.
(when crafted-load-custom-file
(load custom-file t))
(require 'crafted-startup)
(unless crafted-startup-inhibit-splash
(setq initial-buffer-choice #'crafted-startup-screen))
;; Make GC pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
(let ((crafted-info-dir (expand-file-name "docs/dir" user-emacs-directory)))
(when (file-exists-p crafted-info-dir)
(require 'info)
(info-initialize)
(push (file-name-directory crafted-info-dir) Info-directory-list)))