home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

small-init.el (4478B)


      1 (defconst emacs-start-time (current-time))
      2 
      3 (let ((minver 26))
      4   (unless (>= emacs-major-version minver)
      5     (error "Your Emacs is too old -- this configuration requires v%s or higher" minver)))
      6 
      7 ;; load early-init.el before Emacs 27.0
      8 (unless (>= emacs-major-version 27)
      9   (message "Early init: Emacs Version < 27.0")
     10   (load (expand-file-name "early-init.el" user-emacs-directory)))
     11 
     12 (setq inhibit-default-init t)           ; Disable the site default settings
     13 
     14 (setq inhibit-startup-message t
     15       inhibit-startup-screen t)
     16 
     17 (setq confirm-kill-emacs #'y-or-n-p)
     18 (setq initial-major-mode 'fundamental-mode
     19       initial-scratch-message nil)
     20 
     21 (prefer-coding-system 'utf-8)
     22 (set-default-coding-systems 'utf-8)
     23 (set-language-environment 'utf-8)
     24 (set-selection-coding-system 'utf-8)
     25 (set-terminal-coding-system 'utf-8)
     26 
     27 (require 'package)
     28 
     29 (setq package-archives
     30       '(("melpa" . "http://melpa.org/packages/")
     31         ("org" . "https://orgmode.org/elpa/")
     32         ("gnu" . "https://elpa.gnu.org/packages/")))
     33 
     34 (setq package-archive-priorities
     35       '(("melpa" .  3)
     36         ("org" . 2)
     37         ("gnu" . 1)))
     38 
     39 (require 'tls)
     40 
     41 ;; From https://github.com/hlissner/doom-emacs/blob/5dacbb7cb1c6ac246a9ccd15e6c4290def67757c/core/core-packages.el#L102
     42 (setq gnutls-verify-error (not (getenv "INSECURE")) ; you shouldn't use this
     43       tls-checktrust gnutls-verify-error
     44       tls-program (list "gnutls-cli --x509cafile %t -p %p %h"
     45                         ;; compatibility fallbacks
     46                         "gnutls-cli -p %p %h"
     47                         "openssl s_client -connect %h:%p -no_ssl2 -no_ssl3 -ign_eof"))
     48 
     49 ;; Initialise the packages, avoiding a re-initialisation.
     50 (unless (bound-and-true-p package--initialized)
     51   (setq package-enable-at-startup nil)
     52   (package-initialize))
     53 
     54 (setq load-prefer-newer t)              ; Always load newer compiled files
     55 (setq ad-redefinition-action 'accept)   ; Silence advice redefinition warnings
     56 
     57 ;; Init `delight'
     58 (unless (package-installed-p 'delight)
     59   (package-refresh-contents)
     60   (package-install 'delight))
     61 
     62 ;; Configure `use-package' prior to loading it.
     63 (eval-and-compile
     64   (setq use-package-always-ensure nil)
     65   (setq use-package-always-defer nil)
     66   (setq use-package-always-demand nil)
     67   (setq use-package-expand-minimally nil)
     68   (setq use-package-enable-imenu-support t))
     69 
     70 (unless (package-installed-p 'use-package)
     71   (package-refresh-contents)
     72   (package-install 'use-package))
     73 
     74 (eval-when-compile
     75   (require 'use-package))
     76 
     77 (defconst vde/custom-file (locate-user-emacs-file "custom.el")
     78   "File used to store settings from Customization UI.")
     79 
     80 (use-package cus-edit
     81   :config
     82   (setq
     83    custom-file vde/custom-file
     84    custom-buffer-done-kill nil          ; Kill when existing
     85    custom-buffer-verbose-help nil       ; Remove redundant help text
     86    custom-unlispify-tag-names nil       ; Show me the real variable name
     87    custom-unlispify-menu-entries nil)
     88   (unless (file-exists-p custom-file)
     89     (write-region "" nil custom-file))
     90 
     91   (load vde/custom-file 'no-error 'no-message))
     92 
     93 ;; Remove built-in org-mode
     94 (require 'cl-seq)
     95 (setq load-path
     96       (cl-remove-if
     97        (lambda (x)
     98          (string-match-p "org$" x))
     99        load-path))
    100 
    101 (defun vde/el-load-dir (dir)
    102   "Load el files from the given folder `DIR'."
    103   (let ((files (directory-files dir nil "\.el$")))
    104     (while files
    105       (load-file (concat dir (pop files))))))
    106 
    107 (defun vde/short-hostname ()
    108   "Return hostname in short (aka wakasu.local -> wakasu)."
    109   (string-match "[0-9A-Za-z-]+" system-name)
    110   (substring system-name (match-beginning 0) (match-end 0)))
    111 
    112 (add-to-list 'load-path (concat user-emacs-directory "lisp/"))
    113 (add-to-list 'load-path (concat user-emacs-directory "lisp/vorg"))
    114 (require 'init-func)
    115 ;; (vde/el-load-dir (concat user-emacs-directory "/config/"))
    116 ;;
    117 ;; (if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
    118 ;;     (load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))
    119 
    120 (let ((elapsed (float-time (time-subtract (current-time)
    121                                           emacs-start-time))))
    122   (message "Loading %s...done (%.3fs)" load-file-name elapsed))
    123 
    124 (add-hook 'after-init-hook
    125           `(lambda ()
    126              (let ((elapsed
    127                     (float-time
    128                      (time-subtract (current-time) emacs-start-time))))
    129                (message "Loading %s...done (%.3fs) [after-init]"
    130                         ,load-file-name elapsed))) t)