]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Update Emacs configuration to use 'elpaca'
authorEshel Yaron <me@eshelyaron.com>
Mon, 21 Aug 2023 15:27:51 +0000 (17:27 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 21 Aug 2023 15:27:51 +0000 (17:27 +0200)
.emacs.d/early-init.el
.emacs.d/init.el

index 322c763b118e765815e50123a114a5a2b4e68070..c2a774cf3bb4da64bf1f09d3e536b313a1442151 100644 (file)
@@ -7,6 +7,8 @@
 (set-scroll-bar-mode nil)
 (setq mode-line-format nil)
 
+(setq package-enable-at-startup nil)
+
 (unless (eq system-type 'darwin)
   (menu-bar-mode -1)
   (setq initial-frame-alist '((fullscreen . fullboth)
index 5cb7ddb69534a9ccf5789827eea86228c71d25d5..c7fa4b61ee8b4f141645e410800fdc8c6e98724b 100644 (file)
 (pcase system-type
   ('darwin (setq default-frame-alist '((fullscreen . fullboth)))))
 
+;;; Set up Elpaca
+
+(defvar elpaca-installer-version 0.5)
+(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
+(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
+(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
+(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
+                              :ref nil
+                              :files (:defaults (:exclude "extensions"))
+                              :build (:not elpaca--activate-package)))
+(let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
+       (build (expand-file-name "elpaca/" elpaca-builds-directory))
+       (order (cdr elpaca-order))
+       (default-directory repo))
+  (add-to-list 'load-path (if (file-exists-p build) build repo))
+  (unless (file-exists-p repo)
+    (make-directory repo t)
+    (when (< emacs-major-version 28) (require 'subr-x))
+    (condition-case-unless-debug err
+        (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
+                 ((zerop (call-process "git" nil buffer t "clone"
+                                       (plist-get order :repo) repo)))
+                 ((zerop (call-process "git" nil buffer t "checkout"
+                                       (or (plist-get order :ref) "--"))))
+                 (emacs (concat invocation-directory invocation-name))
+                 ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
+                                       "--eval" "(byte-recompile-directory \".\" 0 'force)")))
+                 ((require 'elpaca))
+                 ((elpaca-generate-autoloads "elpaca" repo)))
+            (progn (message "%s" (buffer-string)) (kill-buffer buffer))
+          (error "%s" (with-current-buffer buffer (buffer-string))))
+      ((error) (warn "%s" err) (delete-directory repo 'recursive))))
+  (unless (require 'elpaca-autoloads nil t)
+    (require 'elpaca)
+    (elpaca-generate-autoloads "elpaca" repo)
+    (load "./elpaca-autoloads")))
+(add-hook 'after-init-hook #'elpaca-process-queues)
+(elpaca `(,@elpaca-order))
+
+;;; Install packages
+
+(elpaca (ef-themes
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "ef-themes.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "ef-themes.info"))))
+(elpaca avy)
+(elpaca (bbdb
+         :repo "https://git.savannah.nongnu.org/git/bbdb.git"
+         :files (:defaults "lisp/*.el.in")
+         :pre-build (("./autogen.sh")
+                     ("./configure")
+                     ("make")
+                     ("make install"))))
+(elpaca (corfu
+         :pre-build (("mv" "extensions/corfu-indexed.el" "corfu-indexed.el")
+                     ("rm" "-r" "extensions"))))
+(elpaca (debbugs
+         :pre-build (("makeinfo" "--no-split" "debbugs.texi")
+                     ("makeinfo" "--no-split" "debbugs-ug.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "debbugs.info")
+                     ("install-info" "--dir=dir" "debbugs-ug.info"))))
+(elpaca (devdocs
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "README.texi" "-o" "devdocs.info")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "devdocs.info"))))
+(elpaca diff-hl)
+(elpaca (eat
+         :pre-build (("make" "terminfo")
+                     ("makeinfo" "--no-split" "eat.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "eat.info"))))
+(elpaca (elfeed
+         :pre-build (("pandoc" "-o" "elfeed.texi" "README.md")
+                     ("makeinfo" "--no-split" "elfeed.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "elfeed.info"))))
+(elpaca (esy-publish
+         :repo "git://git.eshelyaron.com/esy-publish.git"))
+(elpaca embark-consult)
+(elpaca emms)
+(elpaca gnu-elpa-keyring-update)
+(elpaca graphql-mode)
+(elpaca htmlize)
+(elpaca ialign)
+(elpaca keycast)
+(elpaca kubernetes)
+(elpaca (ledger-mode
+         :files (:defaults)
+         ;; :pre-build (("makeinfo" "--no-split" "doc/ledger-mode.texi" "-o" "ledger-mode.info")
+         ;;             ("touch" "dir")
+         ;;             ("install-info" "--dir=dir" "ledger-mode.info"))
+         ))
+(elpaca (lin
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "lin.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "lin.info"))))
+(elpaca magit)
+(elpaca (markdown-mode
+         :pre-build (("pandoc" "-o" "markdown-mode.texi" "README.md")
+                     ("makeinfo" "--no-split" "markdown-mode.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "markdown-mode.info"))))
+(elpaca mastodon)
+(elpaca ob-prolog)
+(elpaca orderless)
+(elpaca org)
+(elpaca org-transclusion)
+(elpaca (osm
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "osm.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "osm.info"))))
+(elpaca (openai
+         :repo "https://git.sr.ht/~eshel/openai.el"))
+(elpaca package-lint)
+(elpaca paredit)
+(elpaca (pdf-tools
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "--eval" "(setq org-export-with-broken-links t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "README.texi" "-o" "pdf-tools.info")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "osm.info"))))
+(elpaca rainbow-delimiters)
+(elpaca rainbow-mode)
+(elpaca rg)
+(elpaca smtpmail-multi)
+(elpaca sqlformat)
+(elpaca (sweeprolog
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "sweep.texi")
+                     ("touch" "dir")
+                     ("install-info" "--dir=dir" "sweep.info"))))
+(elpaca terraform-mode)
+(elpaca (vterm
+         :files ("*")
+         :pre-build (("pandoc" "-o" "vterm.org" "README.md")
+                     ("emacs" "--batch" "-l" "ox-texinfo" "vterm.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("makeinfo" "--no-split" "vterm.texi")
+                     ("touch" "dir")
+                     ("install-info"
+                      "--entry" "* vterm::"
+                      "--section=Emacs" "--dir=dir" "vterm.info"))))
+(elpaca whitespace-cleanup-mode)
+
+(elpaca-wait)
+
+(defvar-keymap esy/elpaca-prefix-map
+  :doc "Keymap for `elpaca' commands."
+  "r" #'elpaca-rebuild
+  "e" #'elpaca-recipe
+  "u" #'elpaca-update
+  "U" #'elpaca-update-all
+  "v" #'elpaca-visit
+  "d" #'elpaca-delete
+  "l" #'elpaca-log
+  "i" #'elpaca-info)
+
+(defalias 'esy/elpaca-prefix-map esy/elpaca-prefix-map)
+
 ;;; Set some variables
 
 (setq
  ediff-window-setup-function #'ediff-setup-windows-plain
  duplicate-line-final-position -1
  tramp-kubernetes-namespace "argo"
- ;; make some space in the Packages menu
- package-archive-column-width 12
- package-version-column-width 28
- ;; configure package archives
- package-archives '(("gnu"    . "https://elpa.gnu.org/devel/")
-                    ("nongnu" . "https://elpa.nongnu.org/nongnu-devel/"))
- ;; select some packages to install
- package-selected-packages '(
-                             avy
-                             bbdb
-                             corfu
-                             debbugs
-                             devdocs
-                             diff-hl
-                             eat
-                             eglot
-                             ef-themes
-                             elfeed
-                             embark-consult
-                             emms
-                             gnu-elpa-keyring-update
-                             graphql-mode
-                             htmlize
-                             ialign
-                             keycast
-                             kubernetes
-                             ledger-mode
-                             lin
-                             magit
-                             markdown-mode
-                             mastodon
-                             ob-prolog
-                             openai
-                             orderless
-                             org
-                             org-transclusion
-                             osm
-                             package-lint
-                             paredit
-                             pdf-tools
-                             rainbow-delimiters
-                             rainbow-mode
-                             rg
-                             smtpmail-multi
-                             sqlformat
-                             sweeprolog
-                             terraform-mode
-                             vterm
-                             whitespace-cleanup-mode
-                             )
- package-vc-selected-packages
- '(
-   (avy                     :url "https://github.com/abo-abo/avy.git")
-   (devdocs                 :url "https://github.com/astoff/devdocs.el.git"
-                            :doc "README.org")
-   (diff-hl                 :url "https://github.com/dgutov/diff-hl.git")
-   (elfeed                  :url "https://github.com/skeeto/elfeed.git")
-   (embark-consult          :url "https://github.com/oantolin/embark.git"
-                            :doc "README.org")
-   (esy-publish             :url "git://git.eshelyaron.com/esy-publish.git")
-   (graphql-mode            :url "https://github.com/davazp/graphql-mode.git")
-   (htmlize                 :url "https://github.com/hniksic/emacs-htmlize.git")
-   (ialign                  :url "https://github.com/mkcms/interactive-align.git"
-                            :doc "README.org")
-   (keycast                 :url "https://github.com/tarsius/keycast.git"
-                            :doc "README.org")
-   (kubernetes              :url "https://github.com/kubernetes-el/kubernetes-el.git")
-   (ledger-mode             :url "https://github.com/ledger/ledger-mode.git"
-                            :doc "doc/ledger-mode.texi")
-   (magit                   :url "https://github.com/magit/magit.git"
-                            :lisp-dir "lisp" :doc "docs/magit.texi")
-   (ob-prolog               :url "https://github.com/ljos/ob-prolog.git"
-                            :doc "README.org")
-   (openai                  :url "https://git.sr.ht/~eshel/openai.el")
-   (orderless               :url "https://github.com/oantolin/orderless.git"
-                            :doc "orderless.texi")
-   (osm                     :url "https://github.com/minad/osm.git"
-                            :doc "README.org")
-   (package-lint            :url "https://github.com/purcell/package-lint.git")
-   (rainbow-delimiters      :url "https://github.com/Fanael/rainbow-delimiters.git")
-   (rg                      :url "https://github.com/dajva/rg.el.git")
-   (smtpmail-multi          :url "https://github.com/vapniks/smtpmail-multi.git"
-                            :doc "README.org")
-   (sqlformat               :url "https://github.com/purcell/sqlformat.git")
-   (terraform-mode          :url "https://github.com/syohex/emacs-terraform-mode.git")
-   (vterm                   :url "https://github.com/akermu/emacs-libvterm.git")
-   (whitespace-cleanup-mode :url "https://github.com/purcell/whitespace-cleanup-mode.git")
-   )
-
  ;; configure Org capture templates
  org-capture-templates '(("t" "Todo [inbox]" entry
                           (file+headline "~/org/inbox.org" "Tasks")
                                         "context-menu-mode"))))
  report-emacs-bug-no-explanations t
  submit-emacs-patch-display-help nil)
+
 (setq-default indent-tabs-mode nil)
 
 ;;; Load and enable a custom theme
@@ -830,13 +919,6 @@ Interactively, POINT is point and KILL is the prefix argument."
           (propertize "Emacs"           'face 'success)
           (propertize (emacs-init-time) 'face 'error  )))
 
-;;; Ensure external packages are installed
-
-(package-vc-install-selected-packages)
-
-(package-install-selected-packages)
-
-
 ;;; Extend standard programming mode hooks
 
 (dolist (mode '(bug-reference-prog-mode
@@ -864,13 +946,13 @@ Interactively, POINT is point and KILL is the prefix argument."
 (keymap-global-set "C-c !" #'consult-flymake)
 (keymap-global-set "C-c C" #'esy-publish-create-post)
 (keymap-global-set "C-c O" #'openai-chat)
+(keymap-global-set "C-c e" 'esy/elpaca-prefix-map)
 (keymap-global-set "C-c E" #'elfeed)
 (keymap-global-set "C-c T" #'esy/ttyper)
 (keymap-global-set "C-c R" #'esy/record)
 (keymap-global-set "C-c G" #'gnus)
 (keymap-global-set "C-c M" #'mastodon)
 (keymap-global-set "C-c F" #'esy/find-init-file)
-(keymap-global-set "C-c P" #'list-packages)
 (keymap-global-set "C-c SPC" #'consult-mark)
 (keymap-global-set "C-c 1" #'delete-other-windows)
 (keymap-global-set "C-c 2" #'split-window-below)