Refactor out map.el dependency
Since map-put appears to be deprecated on Emacs 27
This commit is contained in:
parent
fd470f4052
commit
4ce153519c
1 changed files with 18 additions and 22 deletions
|
@ -1,7 +1,5 @@
|
||||||
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
|
||||||
(require 'map)
|
|
||||||
|
|
||||||
;; Eagerly load these libraries because we may be in a session that
|
;; Eagerly load these libraries because we may be in a session that
|
||||||
;; hasn't been fully initialized (e.g. where autoloads files haven't
|
;; hasn't been fully initialized (e.g. where autoloads files haven't
|
||||||
;; been generated or `load-path' populated).
|
;; been generated or `load-path' populated).
|
||||||
|
@ -66,30 +64,28 @@ commands like `doom-cli-packages-install', `doom-cli-packages-update' and
|
||||||
(opt (doom--cli-get-option cli fullflag)))
|
(opt (doom--cli-get-option cli fullflag)))
|
||||||
(unless opt
|
(unless opt
|
||||||
(user-error "Unrecognized switch %S" (concat "--" (match-string 2 arg))))
|
(user-error "Unrecognized switch %S" (concat "--" (match-string 2 arg))))
|
||||||
(map-put
|
(setf (alist-get (doom-cli-option-symbol opt) alist)
|
||||||
alist (doom-cli-option-symbol opt)
|
(or (if (doom-cli-option-args opt)
|
||||||
(or (if (doom-cli-option-args opt)
|
(or (match-string 3 arg)
|
||||||
(or (match-string 3 arg)
|
(pop args)
|
||||||
(pop args)
|
(user-error "%S expected an argument, but got none"
|
||||||
(user-error "%S expected an argument, but got none"
|
fullflag))
|
||||||
fullflag))
|
(if (match-string 3 arg)
|
||||||
(if (match-string 3 arg)
|
(user-error "%S was not expecting an argument, but got %S"
|
||||||
(user-error "%S was not expecting an argument, but got %S"
|
fullflag (match-string 3 arg))
|
||||||
fullflag (match-string 3 arg))
|
fullflag))))))
|
||||||
fullflag))))))
|
|
||||||
|
|
||||||
((string-match "^\\(-\\([a-zA-Z0-9]+\\)\\)$" arg)
|
((string-match "^\\(-\\([a-zA-Z0-9]+\\)\\)$" arg)
|
||||||
(let ((fullflag (match-string 1 arg))
|
(let ((fullflag (match-string 1 arg))
|
||||||
(flag (match-string 2 arg)))
|
(flag (match-string 2 arg)))
|
||||||
(dolist (switch (split-string flag "" t))
|
(dolist (switch (split-string flag "" t))
|
||||||
(if-let (opt (doom--cli-get-option cli (concat "-" switch)))
|
(if-let (opt (doom--cli-get-option cli (concat "-" switch)))
|
||||||
(map-put
|
(setf (alist-get (doom-cli-option-symbol opt) alist)
|
||||||
alist (doom-cli-option-symbol opt)
|
(if (doom-cli-option-args opt)
|
||||||
(if (doom-cli-option-args opt)
|
(or (pop args)
|
||||||
(or (pop args)
|
(user-error "%S expected an argument, but got none"
|
||||||
(user-error "%S expected an argument, but got none"
|
fullflag))
|
||||||
fullflag))
|
fullflag))
|
||||||
fullflag))
|
|
||||||
(user-error "Unrecognized switch %S" (concat "-" switch))))))
|
(user-error "Unrecognized switch %S" (concat "-" switch))))))
|
||||||
|
|
||||||
(arglist
|
(arglist
|
||||||
|
@ -97,7 +93,7 @@ commands like `doom-cli-packages-install', `doom-cli-packages-update' and
|
||||||
(let ((spec (pop arglist)))
|
(let ((spec (pop arglist)))
|
||||||
(when (eq spec '&optional)
|
(when (eq spec '&optional)
|
||||||
(setq spec (pop arglist)))
|
(setq spec (pop arglist)))
|
||||||
(map-put alist spec arg))
|
(setf (alist-get spec alist) arg))
|
||||||
(when (null arglist)
|
(when (null arglist)
|
||||||
(throw 'done t)))
|
(throw 'done t)))
|
||||||
|
|
||||||
|
@ -107,7 +103,7 @@ commands like `doom-cli-packages-install', `doom-cli-packages-update' and
|
||||||
(when (< got expected)
|
(when (< got expected)
|
||||||
(error "Expected %d arguments, got %d" expected got))
|
(error "Expected %d arguments, got %d" expected got))
|
||||||
(when rest
|
(when rest
|
||||||
(map-put alist restvar rest))
|
(setf (alist-get restvar alist) rest))
|
||||||
alist))
|
alist))
|
||||||
|
|
||||||
(defun doom-cli-get (command)
|
(defun doom-cli-get (command)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue