From b6f93e3a55a58396c33ce45ee43145a14eeb1e29 Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Tue, 29 Apr 2025 15:46:06 +0200 Subject: Support Flatpak Emacs Add support for Flatpak Emacs, which notably uses a different XDG configuration directory (`.var/app/org.gnu.emacs/config`), so we need to load relative to `init.el` instead of assuming `.config/emacs`. --- config/emacs/init.el | 23 ++++++++++++++--------- config/emacs/sanemacs.el | 9 ++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/config/emacs/init.el b/config/emacs/init.el index b4460bf..4f56d56 100644 --- a/config/emacs/init.el +++ b/config/emacs/init.el @@ -1,15 +1,13 @@ ;;; -*- lexical-binding: t -*- ;;; TODO(nlordell): -;; 1. Emacs over devcontainers/docker with TRAMP +;; 1. Emacs over TRAMP with `flatpak-spawn --host podman` ;; ;; 2. Setup LLM coding: gptel, aidermacs ;; 3. Try out neocaml - tree-sitter based OCaml mode ;; 4. Take some stuff from Emacs NANO ;; -(load "~/.config/emacs/sanemacs.el" nil t) - (defcustom system-flavour 'plain "The flavour of system. @@ -19,11 +17,18 @@ (const :tag "Development" development)) :group 'convenience) +(defun init/load (name &rest kargs) + "Loads an init file." + (let* ((init-directory (file-name-directory (or load-file-name (buffer-file-name)))) + (file-name (file-name-concat init-directory name)) + (is-optional (plist-get kargs :optional)) + (should-load (or (not is-optional) (file-exists-p file-name)))) + (when should-load + (load file-name nil t)))) + +(init/load "sanemacs.el") (when (eq system-flavour 'development) - (load "~/.config/emacs/flavours/development.el" nil t)) + (init/load "flavours/development.el")) (when (eq system-type 'darwin) - (load "~/.config/emacs/flavours/macos.el" nil t)) - -(let ((local-init "~/.config/emacs/local-init.el")) - (when (file-exists-p local-init) - (load local-init nil t))) + (init/load "flavours/macos.el")) +(init/load "local-init.el" :optional t) diff --git a/config/emacs/sanemacs.el b/config/emacs/sanemacs.el index 5615971..5de05f4 100644 --- a/config/emacs/sanemacs.el +++ b/config/emacs/sanemacs.el @@ -18,13 +18,12 @@ (setq-default cursor-type 'bar indent-tabs-mode nil - show-trailing-whitespace t tab-width 4) (load-theme 'modus-vivendi) -(defun sanemacs/hide-trailing-whitespace () - "Hides trailing whitespace for the current buffer." - (setq show-trailing-whitespace nil)) -(add-hook 'Buffer-menu-mode-hook #'sanemacs/hide-trailing-whitespace) +(defun sanemacs/show-trailing-whitespace () + "Shows trailing whitespace for the current buffer." + (setq show-trailing-whitespace t)) +(add-hook 'prog-mode-hook #'sanemacs/show-trailing-whitespace) ;; Configure features to use `.cache` directory (setq -- cgit v1.2.3