We would need to use `'equal` for comparison, but Emacs 25 only allows `'eq`. Using `advice-add` to override `alist-get` does not work, because `setf` has special handling for `alist-get`. `repl.el`: Switch to a hash table which already supports multiple comparison functions, and changing of elements even in Emacs 25. `eshell/autoload/settings.el`: use conditional set-or-push. Drop `doom*alist-get`, it is unused now. Thanks to @hlissner for the reimplementation.
20 lines
806 B
EmacsLisp
20 lines
806 B
EmacsLisp
;;; emacs/eshell/autoload/settings.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###autodef
|
|
(defun set-eshell-alias! (&rest aliases)
|
|
"Define aliases for eshell."
|
|
(or (cl-evenp (length aliases))
|
|
(signal 'wrong-number-of-arguments (list 'even (length aliases))))
|
|
(after! eshell
|
|
(while aliases
|
|
(let ((alias (pop aliases))
|
|
(command (pop aliases)))
|
|
(if-let* ((oldval (assoc alias +eshell-aliases)))
|
|
(setcdr oldval (list command))
|
|
(push (list alias command) +eshell-aliases))))
|
|
(when (boundp 'eshell-command-aliases-list)
|
|
(if +eshell--default-aliases
|
|
(setq eshell-command-aliases-list
|
|
(append +eshell--default-aliases
|
|
+eshell-aliases))
|
|
(setq eshell-command-aliases-list +eshell-aliases)))))
|