.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

init-elpa.el (2977B)


      1 ;;; init-elpa.el --- package manager -*- lexical-binding: t -*-
      2 
      3 ;;; Commentary:
      4 
      5 ;;; Code:
      6 
      7 ;; straight.el
      8 (setq straight-check-for-modifications '(check-on-save))
      9 (defvar bootstrap-version)
     10 (let ((bootstrap-file
     11        (expand-file-name
     12         "straight/repos/straight.el/bootstrap.el"
     13         (or (bound-and-true-p straight-base-dir)
     14             user-emacs-directory)))
     15       (bootstrap-version 7))
     16   (unless (file-exists-p bootstrap-file)
     17     (with-current-buffer
     18         (url-retrieve-synchronously
     19          "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
     20          'silent 'inhibit-cookies)
     21       (goto-char (point-max))
     22       (eval-print-last-sexp)))
     23   (load bootstrap-file nil 'nomessage))
     24 
     25 ;; install use-package
     26 (if (< emacs-major-version 29)
     27     (straight-use-package 'use-package))
     28 
     29 ;; configure use-package
     30 (setq use-package-always-defer my-enable-lazy-loading
     31       use-package-expand-minimally t
     32       use-package-verbose nil
     33       use-package-compute-statistics t
     34       straight-use-package-version t
     35       straight-use-package-by-default t)
     36 
     37 ;; built-in packages
     38 (setq straight-built-in-pseudo-packages
     39       (cl-union straight-built-in-pseudo-packages
     40                 '(emacs nadvice python image-mode project xref
     41                         eldoc flymake jsonrpc seq external-completion)
     42                 :test 'equal))
     43 
     44 ;; imenu
     45 (setq use-package-form-regexp-eval
     46       `(concat ,(eval-when-compile
     47                   (concat "^\\s-*("
     48                           (regexp-opt '("my-use-package" "use-package" "require") t)
     49                           "\\s-+\\("))
     50                (or (bound-and-true-p lisp-mode-symbol-regexp)
     51                    "\\(?:\\sw\\|\\s_\\|\\\\.\\)+")
     52                "\\)")
     53       use-package-enable-imenu-support t)
     54 
     55 ;; a pointless wrapper
     56 ;; https://github.com/radian-software/straight.el/blob/main/README.md#loading-packages-conditionally
     57 (defmacro my-use-package (name &rest args)
     58   "Like `use-package' but support conditional loading.
     59 
     60 Treat the first of ARGS as a loading condition if it's not a keyword,
     61 otherwise the macro expands to a plain `use-package' declaration."
     62   (declare (indent defun))
     63   (let (condition condition-p)
     64     (when (and args (not (keywordp (car args))))
     65       (setq condition (pop args)
     66             condition-p t))
     67     (let* ((pos (cl-position :straight args))
     68            (val (and pos (nth (1+ pos) args)))
     69            (recipe
     70             (cond
     71              ((or (not pos) (eq val t)) `',name)
     72              ((null val) nil)
     73              ((symbolp val) `',val)
     74              ((memq (car-safe val) '(quote \`)) val)
     75              (t `',val))))
     76       (if (not condition-p)
     77           `(use-package ,name ,@args)
     78         `(progn
     79            ,@(when recipe `((straight-register-package ,recipe))) ;comment this line if you don't want to register unused packages
     80            (when ,condition
     81              (use-package ,name ,@args)))))))
     82 
     83 (provide 'init-elpa)
     84 ;;; init-elpa.el ends here