summaryrefslogtreecommitdiffstats
path: root/lisp/init-package.el
blob: 9797ee9f6bc3b0516b410aba1c3332e68221f394 (plain) (blame)
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
;;; init-package.el --- configure package management  -*- lexical-binding:t -*-
;;; Commentary:
;;; Code:

;; add melpa repo
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;; emacs and gnutls has recurring issues with tls 1.3
;; the original bug was supposedly fixed in 26.3, but resurfaced in 27.2 on
;; macos (https://emacsformacosx.com build)
;;
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341
;; https://www.reddit.com/r/emacs/comments/mk0luk/does_anyone_know_how_to_diagnose_or_fix_emacs_not/
;;
;; disable tls 1.3 if supported by gnutls
(when (and (< emacs-major-version 28)
           (>= libgnutls-version 30603))
  (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))

(defun mpolden/require-package (package)
  "Install given PACKAGE if it's not already installed."
  (or (package-installed-p package)
      (progn
        (unless (assoc package package-archive-contents)
          (package-refresh-contents))
        (package-install package))))

(defvar mpolden/inhibited-features nil "List of features that should not be loaded.")

(defun mpolden/maybe-require (feature)
  "Load FEATURE if it's not inhibited."
  (unless (memq feature mpolden/inhibited-features)
    (require feature)))

;; install use-package and diminish
(mpolden/require-package 'use-package)
(mpolden/require-package 'diminish)

;; speed up loading of use-package and dependencies
(eval-when-compile
  (require 'use-package))
(require 'diminish)
(require 'bind-key)

(provide 'init-package)

;;; init-package.el ends here