use elpa org and update copilot config

This commit is contained in:
Peter Tillemans 2025-06-02 16:13:05 +02:00
parent bbad96beef
commit 68e0c5f374
2 changed files with 55 additions and 95 deletions

View file

@ -1,67 +0,0 @@
;;; Bootstrap elpaca
(setq package-enable-at-startup nil)
;; for guix emacs-next packages you can find the date with
;; ➜ stat /gnu/store/*emacs-next-[23]*.drv | rg Birth | cut -d' ' -f3 | tr -d '-'
;; 20240727
;;
;; it is possible there are more so probably the most recent one is the one to use.
(when emacs-build-time
(setq elpaca-core-date (format-time-string "%Y%m%d" emacs-build-time)))
(defvar elpaca-installer-version 0.11)
(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 :depth 1
:files (:defaults "elpaca-test.el" (: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 (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(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))
;; Enable :elpaca use-package keyword.
(elpaca elpaca-use-package
(elpaca-use-package-mode))
;; tangling to generate scripts for the local bin directory. This
;; causes the name of the scripts to be returned in the car of the
;; tangle command which is used to load the file. The net result is
;; that not the initialization is loaded, but the first exported
;; script.
(use-package ob-tangle)
(let ((src (concat user-emacs-directory "init.org"))
(tgt (concat user-emacs-directory "init.el"))
(enable-local-variables nil)) ;; disable local variables to prevent asking confirmation before frame is available
(when (file-newer-than-file-p src tgt)
(message "tangling init.org")
(delete-file tgt)
(org-babel-tangle-file src tgt "emacs-lisp")))

View file

@ -35,11 +35,33 @@ one to use.
- [[https://github.com/jwiegley/dot-emacs/blob/master/init.org][John Wiegley's .emacs file]] - [[https://github.com/jwiegley/dot-emacs/blob/master/init.org][John Wiegley's .emacs file]]
- [[https://github.com/TheBB/dotemacs/blob/master/init.el][Eivind Fonn's init.el]] - [[https://github.com/TheBB/dotemacs/blob/master/init.el][Eivind Fonn's init.el]]
** Make tangled file read-only
Add a preamble to the file to ensure some global settings, most
importantly make the file read-only to avoid editing the tangled file by
accident instead of the source in the org-mode file.
#+BEGIN_SRC emacs-lisp
;; init.el --- Literate configuration for Emacs -*- lexical-binding: t; read-only-mode: t; -*-
;;
;;; Commentary:
;;
;; DO NOT EDIT!!!
;;
;; This file is automatically generated from the source in *init.org*.
;;
#+END_SRC
Also immediately set lexical binding mode.
** Global Configuration ** Global Configuration
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq snm-enable-evil t) ;; enable evil bindings (setq snm-enable-evil t) ;; enable evil bindings
(setq snm-docker-executable 'podman) ;; use docker or podman (setq snm-docker-executable 'podman) ;; use docker or podman
(use-package org
:ensure t)
#+END_SRC #+END_SRC
* First Things First * First Things First
@ -47,6 +69,7 @@ one to use.
** Bootstrapping Emacs Configuration ** Bootstrapping Emacs Configuration
#+BEGIN_SRC emacs-lisp :tangle "early-init.el" #+BEGIN_SRC emacs-lisp :tangle "early-init.el"
;; early-init.el --- Bootstrap Emacs -*- lexical-binding: t; read-only-mode: t; -*-
;;; Bootstrap elpaca ;;; Bootstrap elpaca
(setq package-enable-at-startup nil) (setq package-enable-at-startup nil)
@ -111,7 +134,7 @@ configuration on multiple machines and fetch changes with a ~git pull~
outside emacs so there is on opportunity to tangle the new file. If outside emacs so there is on opportunity to tangle the new file. If
I see it is outdated I tangle it. I see it is outdated I tangle it.
#+BEGIN_SRC emacs-lisp :tangle "early-init.el" #+BEGIN_SRC emacs-lisp :tangle no
;; tangling to generate scripts for the local bin directory. This ;; tangling to generate scripts for the local bin directory. This
;; causes the name of the scripts to be returned in the car of the ;; causes the name of the scripts to be returned in the car of the
;; tangle command which is used to load the file. The net result is ;; tangle command which is used to load the file. The net result is
@ -128,24 +151,6 @@ I see it is outdated I tangle it.
#+END_SRC #+END_SRC
** Make tangled file read-only
Add a preamble to the file to ensure some global settings, most
importantly make the file read-only to avoid editing the tangled file by
accident instead of the source in the org-mode file.
#+BEGIN_SRC emacs-lisp
;; init.el --- Literate configuration for Emacs -*- lexical-binding: t; read-only-mode: t; -*-
;;
;;; Commentary:
;;
;; DO NOT EDIT!!!
;;
;; This file is automatically generated from the source in *init.org*.
;;
#+END_SRC
Also immediately set lexical binding mode.
** Set the garbage collector threshold, to avoid collections ** Set the garbage collector threshold, to avoid collections
The emacs history goes back to times where memory was counted in The emacs history goes back to times where memory was counted in
@ -1221,8 +1226,8 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
#+END_SRC #+END_SRC
*** Rust Support *** Rust Support
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp
;; configure rust support ;; configure rust support
(let* ((release-date "2023-10-30") (let* ((release-date "2023-10-30")
(os (pcase system-type (os (pcase system-type
@ -1232,10 +1237,12 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
(_ "unknown"))) (_ "unknown")))
(releases-url "https://github.com/rust-lang/rust-analyzer/releases/download/") (releases-url "https://github.com/rust-lang/rust-analyzer/releases/download/")
(download-url (concat releases-url release-date "/rust-analyzer-" os ".gz")) (download-url (concat releases-url release-date "/rust-analyzer-" os ".gz"))
(rust-analyzer (rust-analyzer (file-name-concat
(file-name-concat user-emacs-directory
user-emacs-directory (concat "lsp/rust-analyzer"
(concat "lsp/rust-analyzer" (if (eq system-type 'windows-nt) ".exe" ""))))) (if (eq system-type 'windows-nt)
".exe"
"")))))
(if (not (file-exists-p rust-analyzer)) (if (not (file-exists-p rust-analyzer))
(let ((rust-analyzer-archive (concat rust-analyzer ".gz" ))) (let ((rust-analyzer-archive (concat rust-analyzer ".gz" )))
(message "install rust-analyzer from %s at %s" download-url rust-analyzer) (message "install rust-analyzer from %s at %s" download-url rust-analyzer)
@ -1247,9 +1254,10 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
(use-package rustic (use-package rustic
:ensure t :ensure t
:init :after (flymake flycheck eglot)
(setq rustic-lsp-client 'eglot)) :init (setq rustic-lsp-client 'eglot))
#+END_SRC #+END_SRC
*** OCaml Support *** OCaml Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; configure Ocaml support ;; configure Ocaml support
@ -1862,6 +1870,25 @@ templates to be generated. By default it uses
#+END_SRC #+END_SRC
** Org Mode ** Org Mode
*** Configure Org Mode
#+BEGIN_SRC emacs-lisp
(use-package org-mode
:mode "\\.org$"
:ensure nil
:after org
:config
(progn
(setq org-log-done 'time)
(setq org-confirm-babel-evaluate nil)
(setq org-export-babel-evaluate nil)
(setq org-html-validation-link nil)
;; ... more stuff
)
)
#+END_SRC
*** Mixed Pitch Support by Default in Org *** Mixed Pitch Support by Default in Org
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun snm-org-mode-config () (defun snm-org-mode-config ()
@ -2869,7 +2896,7 @@ integration in Emacs.
(report-time-since-load "Programming - Copilot Support") (report-time-since-load "Programming - Copilot Support")
#+END_SRC #+END_SRC
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC emacs-lisp :tangle no
(use-package copilot (use-package copilot
:ensure (copilot :host github :repo "zerolfx/copilot.el" :ensure (copilot :host github :repo "zerolfx/copilot.el"
:branch "main" :branch "main"
@ -3344,7 +3371,7 @@ inspiration
:user-name ,(concat :user-name ,(concat
(auth-source-pass--get-attr "user" data) (auth-source-pass--get-attr "user" data)
"@" "@"
(car (s-split "\\." (system-name) ))) (car (string-split (system-name) "\\.")))
:password ,(auth-source-pass--get-attr 'secret data) :password ,(auth-source-pass--get-attr 'secret data)
:channels '("#emacs" :channels '("#emacs"
"#erc" "#erc"