simplified and better monitoring of init scripts

This commit is contained in:
Peter Tillemans 2024-08-11 11:36:44 +02:00
parent bcbd883576
commit 6cc0a9871c
2 changed files with 103 additions and 43 deletions

View file

@ -82,6 +82,7 @@
;; this is a good time to check if the crafted-emacs repo is fresh ;; this is a good time to check if the crafted-emacs repo is fresh
;; - we just updated the init.org file so we expect changes. ;; - we just updated the init.org file so we expect changes.
;; - or this is the initial tangling and we need the repo to exist. ;; - or this is the initial tangling and we need the repo to exist.
(message "checking crafted emacs repo...")
(check-crafted-emacs-fresh-repo) (check-crafted-emacs-fresh-repo)
))) )))
@ -95,3 +96,4 @@
(load (expand-file-name "modules/crafted-package-config" crafted-emacs-home)) (load (expand-file-name "modules/crafted-package-config" crafted-emacs-home))
(load (expand-file-name "modules/crafted-early-init-config" crafted-emacs-home)) (load (expand-file-name "modules/crafted-early-init-config" crafted-emacs-home))
(message "early-init done")

128
init.org
View file

@ -1,6 +1,6 @@
#+TITLE: My Emacs Configuration #+TITLE: My Emacs Configuration
#+PROPERTY: header-args :tangle yes #+PROPERTY: header-args :tangle yes
#+PROPERTY: header-args:emacs-lisp :lexical yes :tangle yes :comments both :padline yes #+PROPERTY: header-args:emacs-lisp :lexical yes :tangle yes :comments nil :padline yes
* Literate Configuration for Emacs * Literate Configuration for Emacs
@ -39,6 +39,7 @@ one to use.
- [[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]]
* First Things First * First Things First
** Make tangled file read-only ** Make tangled file read-only
Add a preamble to the file to ensure some global settings, most Add a preamble to the file to ensure some global settings, most
@ -73,7 +74,7 @@ Also immediately set lexical binding mode.
"Report the time since the file was init script was started. "Report the time since the file was init script was started.
If SUFFIX is provided, it is appended to the message." If SUFFIX is provided, it is appended to the message."
(message "Loading init... (%.3fs) %s" (message "%.3fs: %s"
(float-time (time-subtract (current-time) emacs-start-time)) (float-time (time-subtract (current-time) emacs-start-time))
suffix)) suffix))
@ -111,7 +112,7 @@ then load it.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun pti-reload-dir-locals-for-current-buffer () (defun pti-reload-dir-locals-for-current-buffer ()
"reload dir locals for the current buffer" "Reload dir locals for the current buffer."
(interactive) (interactive)
(let ((enable-local-variables :all)) (let ((enable-local-variables :all))
(hack-dir-local-variables-non-file-buffer))) (hack-dir-local-variables-non-file-buffer)))
@ -129,28 +130,36 @@ provided. This functions uses the releases API to get the latest
metadata and get the version number from the JSON. metadata and get the version number from the JSON.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun pti-with-latest-github-version (repo f) (require 'url)
(defun pti-latest-github-release (repo)
"Return the latest version of the releases for REPO. "Return the latest version of the releases for REPO.
The repo should be in the form of 'owner/repo'. The function F The repo should be in the form of `owner/repo'."
will be called with the version in format 'vX.Y.Z' as the only argument." (with-temp-buffer
(url-retrieve (url-insert-file-contents
(format "https://api.github.com/repos/%s/releases/latest" repo) (format "https://api.github.com/repos/%s/releases/latest" repo))
(lambda (events)
(message "Events: %s" events)
(goto-char url-http-end-of-headers)
(let ((json-object-type 'plist)
(json-key-type 'symbol)
(json-array-type 'vector))
(let ((result (json-read))) (let ((result (json-read)))
(message "Latest version: %s" (plist-get result 'name)) (cdr (assoc 'name result)))))
(funcall f (plist-get result 'name))
)))))
#+END_SRC #+END_SRC
#+RESULTS:
: pti-latest-github-release
#+BEGIN_SRC emacs-lisp :results value
(pti-latest-github-release "plantuml/plantuml")
#+END_SRC
#+RESULTS:
: v1.2024.6
* Crafted Emacs * Crafted Emacs
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Crafted Emacs")
#+END_SRC
When I could not solve the persistent slowness I experienced on When I could not solve the persistent slowness I experienced on
Windows using Doom Emacs, I wanted to switch to a more hands-on Windows using Doom Emacs, I wanted to switch to a more hands-on
minimal Emacs configuration. I just watched the 'Rational Emacs' minimal Emacs configuration. I just watched the 'Rational Emacs'
@ -181,7 +190,7 @@ Lists and installs a variety of packages and includes custom configurations for
(require 'crafted-writing-packages) (require 'crafted-writing-packages)
(require 'crafted-ui-packages) (require 'crafted-ui-packages)
(message "loading packages") (report-time-since-load "loading packages")
(crafted-package-install-selected-packages) (crafted-package-install-selected-packages)
(elpaca-wait) (elpaca-wait)
@ -198,6 +207,11 @@ Lists and installs a variety of packages and includes custom configurations for
: pti-org-config : pti-org-config
* Integration with Environment * Integration with Environment
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Integration with Environment")
#+END_SRC
** Set default Coding System to Use UTF-8 Everywhere ** Set default Coding System to Use UTF-8 Everywhere
Ensures UTF-8 is the default coding system everywhere. Ensures UTF-8 is the default coding system everywhere.
@ -332,6 +346,11 @@ It provides a minor-mode
* Editor Features * Editor Features
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Editor Features")
#+END_SRC
** Evil Vim Keybindings ** Evil Vim Keybindings
I configure all my apps to use vim keybindings if possible to maximise I configure all my apps to use vim keybindings if possible to maximise
@ -626,7 +645,7 @@ whether to put it under writing, comms or programming as it is equally
)) ))
(ellama-sessions-directory (expand-file-name "~/Dropbox/ellama-sessions")) (ellama-sessions-directory (expand-file-name "~/Dropbox/ellama-sessions"))
:config :config
(message "Ellama is available")) (report-time-since-load "Ellama is available"))
#+END_SRC #+END_SRC
It seems the *gpt-4o* model provides better responses. I should It seems the *gpt-4o* model provides better responses. I should
@ -708,6 +727,11 @@ Emacs' direnv module gives first class support to Emacs projects so they use the
This enables direnv globally. This enables direnv globally.
* Writing and Planning * Writing and Planning
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Writing and Planning")
#+END_SRC
** Org Mode ** Org Mode
*** Mixed Pitch Support by Default in Org *** Mixed Pitch Support by Default in Org
@ -832,20 +856,15 @@ interactive to manually install the latest version if needed.
This function is interactive to make it easy to upgrade to This function is interactive to make it easy to upgrade to
the latest, current version with `M-x pti-download-latest-plantuml'." the latest, current version with `M-x pti-download-latest-plantuml'."
(interactive) (interactive)
(pti-with-latest-github-version (let* ((version (pti-latest-github-release "plantuml/plantuml"))
"plantuml/plantuml" (url (format
(lambda (version)
(let ((url (format
"https://github.com/plantuml/plantuml/releases/download/%s/plantuml-%s.jar" "https://github.com/plantuml/plantuml/releases/download/%s/plantuml-%s.jar"
version (substring version 1)))) version (substring version 1))))
(message "Downloading PlantUML version %s from %s" version url) (message "Downloading PlantUML version %s from %s" version url)
(url-copy-file (url-copy-file
url url
(concat user-emacs-directory "plantuml.jar") (concat user-emacs-directory "plantuml.jar")
)))) t)))
)
(let ((plantuml-jar (concat user-emacs-directory "plantuml.jar"))) (let ((plantuml-jar (concat user-emacs-directory "plantuml.jar")))
(if (not (file-exists-p plantuml-jar)) (if (not (file-exists-p plantuml-jar))
@ -1428,7 +1447,13 @@ We can add a list of queries
**** TODO explain what denote-dired-mode-in-directories does. **** TODO explain what denote-dired-mode-in-directories does.
* Programming * Programming
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Programming")
#+END_SRC
** Programming Support Infrastructure ** Programming Support Infrastructure
*** Integration with LSP Servers for language support *** Integration with LSP Servers for language support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; configure eglot-mode ;; configure eglot-mode
@ -1471,6 +1496,18 @@ We can add a list of queries
#+END_SRC #+END_SRC
*** Flymake Support
#+BEGIN_SRC emacs-lisp
(after-load 'flymake
(evil-define-key 'normal flymake-mode-map
(kbd "]d") #'flymake-goto-next-error
(kbd "[d") #'flymake-goto-prev-error
))
#+END_SRC
*** Use Treesitter parser support *** Use Treesitter parser support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1498,6 +1535,7 @@ We can add a list of queries
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src") (tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src") (typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml"))) (yaml "https://github.com/ikatyang/tree-sitter-yaml")))
:hook :hook
((prog . treesit-inspect-mode))) ((prog . treesit-inspect-mode)))
@ -1691,7 +1729,7 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
(if (not (file-exists-p archive)) (if (not (file-exists-p archive))
(url-copy-file download-url archive)) (url-copy-file download-url archive))
(call-process "tar" nil "*snam-install*" t "-C" jdtls-dir "-xzvf" archive ) (call-process "tar" nil "*snam-install*" t "-C" jdtls-dir "-xzvf" archive )
(message "jdtls installed at %s" jdtls-prog))) (report-time-since-load "jdtls installed at %s" jdtls-prog)))
(with-eval-after-load 'eglot (with-eval-after-load 'eglot
(progn (progn
(setenv "JAVA_HOME" (getenv "GUIX_PROFILE")) (setenv "JAVA_HOME" (getenv "GUIX_PROFILE"))
@ -1798,11 +1836,11 @@ Map the keymap consistently to the eglot mappings.
(let ((default-directory (expand-file-name snam-vscode-js-debug-dir))) (let ((default-directory (expand-file-name snam-vscode-js-debug-dir)))
(vc-git-clone "https://github.com/microsoft/vscode-js-debug.git" "." nil) (vc-git-clone "https://github.com/microsoft/vscode-js-debug.git" "." nil)
(message "git repository created") (report-time-since-load "git repository created")
(call-process "npm" nil "*snam-install*" t "install") (call-process "npm" nil "*snam-install*" t "install")
(message "npm dependencies installed") (report-time-since-load "npm dependencies installed")
(call-process "npx" nil "*snam-install*" t "gulp" "dapDebugServer") (call-process "npx" nil "*snam-install*" t "gulp" "dapDebugServer")
(message "vscode-js-debug installed"))) (report-time-since-load "vscode-js-debug installed")))
(setq snam-codelldb-dir (file-name-concat user-emacs-directory "dape/codelldb")) (setq snam-codelldb-dir (file-name-concat user-emacs-directory "dape/codelldb"))
(defun snam-install-codelldb () (defun snam-install-codelldb ()
@ -1819,9 +1857,9 @@ Map the keymap consistently to the eglot mappings.
(release-url (concat "https://github.com/vadimcn/codelldb/releases/download/v" version "/codelldb-" arch "-" os ".vsix"))) (release-url (concat "https://github.com/vadimcn/codelldb/releases/download/v" version "/codelldb-" arch "-" os ".vsix")))
(mkdir default-directory t) (mkdir default-directory t)
(url-copy-file release-url "codelldb.zip" t) (url-copy-file release-url "codelldb.zip" t)
(message "codelldb archive downloaded") (report-time-since-load "codelldb archive downloaded")
(call-process "unzip" nil "*snam-install*" t "codelldb.zip") (call-process "unzip" nil "*snam-install*" t "codelldb.zip")
(message "codelldb installed") (report-time-since-load "codelldb installed")
)) ))
;; configure dape (dap-mode) ;; configure dape (dap-mode)
@ -1938,7 +1976,7 @@ the moment.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package gitlab-ci-mode (use-package gitlab-ci-mode
:ensure (:host gitlab.com :repo "ptillemans/gitlab-ci-mode" :branch "fixes_2024") :ensure (:host gitlab :repo "ptillemans/gitlab-ci-mode" :branch "fixes_2024")
:mode "\\.gitlab-ci\\.yml\\'" :mode "\\.gitlab-ci\\.yml\\'"
:custom :custom
(gitlab-ci-url "https://gitlab.melexis.com") (gitlab-ci-url "https://gitlab.melexis.com")
@ -1949,6 +1987,11 @@ the moment.
: [nil 26292 38256 549743 nil elpaca-process-queues nil nil 11000 nil] : [nil 26292 38256 549743 nil elpaca-process-queues nil nil 11000 nil]
* Communication and Interwebs * Communication and Interwebs
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Communication and Interwebs")
#+END_SRC
** ERC configuration ** ERC configuration
Set up ERC, an IRC client for Emacs, to automatically join specific channels and log in: Set up ERC, an IRC client for Emacs, to automatically join specific channels and log in:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -2016,7 +2059,7 @@ I like to have my IRC channels on workspace 5 in *i3*.
(call-process "i3" nil nil nil "move window to workspace 5") (call-process "i3" nil nil nil "move window to workspace 5")
(snam-erc) (snam-erc)
(call-process "i3" nil nil nil "workspace 5") (call-process "i3" nil nil nil "workspace 5")
(message "Waiting to connect to IRC...") (report-time-since-load "Waiting to connect to IRC...")
(dotimes (i 12) (dotimes (i 12)
(unless (member channel (mapcar 'buffer-name (erc-channel-list nil))) (unless (member channel (mapcar 'buffer-name (erc-channel-list nil)))
(sleep-for 0.25))) (sleep-for 0.25)))
@ -2105,6 +2148,11 @@ The commands this package offers:
as apparently is was abused too much. as apparently is was abused too much.
* Finishing Touches * Finishing Touches
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Finishing Touches")
#+END_SRC
** Tell the module system that *init.el* is available ** Tell the module system that *init.el* is available
Indicates the ~init.el~ file is provided by and ends here: Indicates the ~init.el~ file is provided by and ends here:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -2112,6 +2160,11 @@ Indicates the ~init.el~ file is provided by and ends here:
;;; init.el ends here ;;; init.el ends here
#+END_SRC #+END_SRC
* Future * Future
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Future")
#+END_SRC
** TODO Decide about general keybindings. ** TODO Decide about general keybindings.
The *general* package offers enhanced support for *evil* keybindings, The *general* package offers enhanced support for *evil* keybindings,
notably it integrates with *use-package* to define keybindings which notably it integrates with *use-package* to define keybindings which
@ -2123,6 +2176,11 @@ enough value but I just removed it, so it'll have to wait a bit.
see [[https://github.com/gicrisf/ox-zola][ox-zola]] for exporting org-mode to zola markdown. see [[https://github.com/gicrisf/ox-zola][ox-zola]] for exporting org-mode to zola markdown.
* Final Words * Final Words
#+BEGIN_SRC emacs-lisp
(report-time-since-load "Final Words")
#+END_SRC
This is the end of the configuration file. This is the end of the configuration file.
Add a variable so the file is tangling itself each time it is saved. Add a variable so the file is tangling itself each time it is saved.