Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run pcase-defmacro for interfaces #2481

Merged
merged 2 commits into from
Dec 30, 2020
Merged

Run pcase-defmacro for interfaces #2481

merged 2 commits into from
Dec 30, 2020

Conversation

leungbk
Copy link
Member

@leungbk leungbk commented Dec 29, 2020

Closes #2285.

An alternate approach is to write a separate wrapper entirely (untested):

(defmacro lsp-dcase (expr-val &rest clauses)
  "Destructure EXPR-VAL upon reaching the first matching clause,
then execute the corresponding body form."
  (-when-let (((bindings body) . remaining-clauses) clauses)
    `(-if-let (,bindings ,expr-val)
         (progn ,@body)
       (lsp-dcase ,expr-val ,remaining-clauses))))

But using pcase-defmacro instead lets us use the existing pcase patterns, most notably the seq pattern.

lsp-mode.el Show resolved Hide resolved
Copy link
Member

@yyoncho yyoncho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! Consider adding a unit test for that.

@leungbk leungbk force-pushed the pcase branch 2 times, most recently from e3cdd65 to 9abecd3 Compare December 29, 2020 23:43
@leungbk
Copy link
Member Author

leungbk commented Dec 29, 2020

OK, I added some tests.

@leungbk leungbk force-pushed the pcase branch 2 times, most recently from aa6bd4e to 12c7fd8 Compare December 30, 2020 02:12
@leungbk leungbk force-pushed the pcase branch 8 times, most recently from cc51435 to 1422122 Compare December 30, 2020 04:09
@yyoncho
Copy link
Member

yyoncho commented Dec 30, 2020

OK, I added some tests.

Thank you. FYI the reason I am requesting tests is that we already have a good test suite for that particular feature and it is relatively straightforward to add them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make pcase match protocol-specified types
4 participants