Skip to content

Commit

Permalink
Add reverse zapp like parsing with "-"
Browse files Browse the repository at this point in the history
Let - act as an reader macro for applying options :env :program :args
  • Loading branch information
svaante committed Sep 14, 2024
1 parent fb7d524 commit 50a62a1
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions dape.el
Original file line number Diff line number Diff line change
Expand Up @@ -5078,8 +5078,28 @@ If LOOSE-PARSING is non nil ignore arg parsing failures."
(string-trim)
(string-empty-p)
(not))
(push (read (current-buffer))
read-config))
(let ((thing (read (current-buffer))))
(cond
((eq thing '-)
(cl-loop
with command = (split-string-shell-command
(buffer-substring (point) (point-max)))
with setvar = "\\`\\([A-Za-z_][A-Za-z0-9_]*\\)=\\(.*\\)\\'"
for cell on command for (program . args) = cell
if (string-match setvar program)
append `(,(intern (concat ":" (match-string 1 program)))
,(match-string 2 program))
into env and for program = nil
when (or (and (not program) (not args)) program) do
(setq read-config
(append (nreverse
(append (when program `(:program ,program))
(when args `(:args ,(apply 'vector args)))
(when env `(:env ,env))))
read-config))
(throw 'done nil)))
(t
(push thing read-config)))))
(error
(unless loose-parsing
(user-error "Unable to parse options %s"
Expand Down Expand Up @@ -5171,7 +5191,8 @@ nil."
(mapcar (lambda (suggestion) (format "%s " suggestion))
dape--minibuffer-suggestions))))
;; Complete config args
((and (alist-get key dape-configs)
((and (not (plist-member args '-))
(alist-get key dape-configs)
(or (and (plistp args)
(thing-at-point 'whitespace))
(cl-loop with p = (point)
Expand Down

0 comments on commit 50a62a1

Please sign in to comment.