mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user