From 57932ff37ff184a85f69fe4840fd3ceae5ba90ce Mon Sep 17 00:00:00 2001 From: Lucas Sta Maria Date: Sun, 6 Aug 2023 00:45:31 -0700 Subject: [PATCH] feat: add `lists->alist` function to emacs config Signed-off-by: Lucas Sta Maria --- .config/ambit/config.ambit | 1 + .emacs.d/include/utils.el | 22 ++++++++++++++++++++++ .emacs.d/init.el | 1 + 3 files changed, 24 insertions(+) create mode 100644 .emacs.d/include/utils.el diff --git a/.config/ambit/config.ambit b/.config/ambit/config.ambit index c5112be..073af49 100644 --- a/.config/ambit/config.ambit +++ b/.config/ambit/config.ambit @@ -49,6 +49,7 @@ include/[ general.el, misc.el, + utils.el, orgconfig.el, mu4econfig.el, racket.el, diff --git a/.emacs.d/include/utils.el b/.emacs.d/include/utils.el new file mode 100644 index 0000000..8d5813b --- /dev/null +++ b/.emacs.d/include/utils.el @@ -0,0 +1,22 @@ +;;; utils.el --- Utility functions. +;;; Commentary: +;; Provides utility functions. +;;; Code: + +(defun lists->alist (l1 l2) + "Transform lists L1 (keys) and L2 (values) into a single alist." + (cond ((and (null l1) + (null l2)) + '()) + ((or (null l1) + (null l2)) + (error "Lists L1 and L2 have to be of equal length")) + ((and (consp l1) + (consp l2)) + (cons `(,(car l1) . ,(car l2)) + (lists->alist (cdr l1) + (cdr l2)))))) + +(provide 'utils) + +;;; utils.el ends here diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 541b648..23b296a 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -71,6 +71,7 @@ (load-library "general") (load-library "misc") +(load-library "utils") (load-library "orgconfig") (load-library "mu4econfig") (load-library "racket")