Skip to content

Commit

Permalink
Fix &map pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
okamsn committed Jan 26, 2024
1 parent e9195fd commit 9421941
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions loopy-destructure.el
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ holding the property list."
collect `(,'\, ,pat))))))))

(defun loopy--pcase-pat-&map-pattern (map-vars)
(let ((mapsym (gensym "map"))
(keysym (gensym "key")))
(let ((mapsym (gensym "map")))
`(and (pred mapp)
,@(mapcar (pcase-lambda ((and var-form
(or (seq key var default supplied)
Expand All @@ -496,10 +495,10 @@ holding the property list."
`(app (lambda (,mapsym)
;; Using `map-contains-key' is a slower,
;; but more correct method.
(macroexp-let2* ((,keysym ,key))
(if (map-contains-key ,mapsym ,keysym)
(cons t (map-elt ,mapsym ,keysym))
(cons nil ,default))))
,(macroexp-let2* ((keysym key))
`(if (map-contains-key ,mapsym ,keysym)
(cons t (map-elt ,mapsym ,keysym))
(cons nil ,default))))
(,'\` ((,'\, ,supplied) . (,'\, ,var)))))
(default
`(app (lambda (,mapsym) (map-elt ,mapsym ,key ,default))
Expand Down

0 comments on commit 9421941

Please sign in to comment.