feat(utils): add siren-prepend and siren-append macros

These macros work more or less like add-to-list, except they will always
leave ELEMENT as the first/last element in the list, while add-to-list
does not modify the list if ELEMENT is already present anywhere in the
list.
This commit is contained in:
2022-07-30 21:35:24 +01:00
parent 6fc53bc58e
commit bbd8f11719

View File

@@ -7,6 +7,14 @@
;;; Code:
(defmacro siren-prepend (list-var element)
"Add ELEMENT to beginning of LIST-VAR, removing duplicates."
`(setq ,list-var (cons ,element (remove ,element ,list-var))))
(defmacro siren-append (list-var element)
"Add ELEMENT to end of LIST-VAR, removing duplicates."
`(setq ,list-var (append (remove ,element ,list-var) (list ,element))))
(defun siren-recursive-add-to-load-path (dir)
"Add DIR and all its sub-directories to `load-path'."
(add-to-list 'load-path dir)