From ab357d3c1032b64a5403b5b66d8bd781346dbdb6 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 12 Sep 2026 02:00:28 -0700 Subject: emacs: Add all snippets files into my guix configuration --- oni/home/services/emacs.scm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/oni/home/services/emacs.scm b/oni/home/services/emacs.scm index cf8b862..7d0c168 100644 --- a/oni/home/services/emacs.scm +++ b/oni/home/services/emacs.scm @@ -1,4 +1,5 @@ (define-module (oni home services emacs) + #:use-module (ice-9 ftw) #:use-module ((gnu services configuration) #:select (serialize-package define-configuration @@ -202,6 +203,9 @@ (org-caldav maybe-home-emacs-org-caldav-configuration "Configuration for org-caldav.") + (yasnippet-snippet-directories + (list-of-strings '()) + "The list of directiories that need to be scanned for yasnippet snippets.") (configurations (text-config '()) "A list of other configuration files to autoload")) @@ -256,6 +260,22 @@ #:log-file (format #f "~a/.local/var/log/emacs.log" (getenv "HOME")))) (stop #~(make-kill-destructor))))) +(define (home-emacs-configuration-collect-snippets config) + (let ((snippets (file-system-tree "emacs/.emacs.d/snippets"))) + (apply append (let loop ((prefix (car snippets)) + (current-file (car snippets)) + (files (cddr snippets))) + (if (null? files) + (list (string-append ".emacs.d/" prefix) + (local-file (string-append "emacs/.emacs.d/" prefix) + (if (string-prefix? "." current-file) + (string-drop current-file 1) + current-file))) + (map (lambda (f) (loop (string-append prefix "/" (car f)) + (car f) + (cddr f))) + files)))))) + (define (home-emacs-config-files config) `((".emacs.d/init.el" ,(mixed-text-file @@ -321,7 +341,8 @@ (home-emacs-configuration-custom-file config)) "(load custom-file :noerror)\n" "(provide 'init)\n" - ";;; init.el ends here\n")))) + ";;; init.el ends here\n")) + ,@(home-emacs-configuration-collect-snippets config))) (define home-emacs-service-type (service-type -- cgit v1.3-2-g0d8e