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

Make el-patch-get use the only variant by default #67

Closed
wants to merge 1 commit into from

Conversation

dsedivec
Copy link

I make significant use of el-patch-validate non-interactively in my init file. These usages broke when I updated to the latest version of el-patch, because an invocation that used to work such as

(el-patch-validate 'some-function 'defun 'nomsg)

was now unable to look up the patch I had just applied to some-function. I believe this is happening because el-patch-validate was allowing you to omit variant, and nil is not a possible variant. From reading the code, I believe all variants will be a cons of (advice name). Therefore when el-patch-validate calls (el-patch-get 'some-function 'defun nil), it will never get a result, and el-patch-validate will always fail.

(nil) could perhaps be called "the default variant", but I didn't see it hard coded anywhere else in el-patch, so I wasn't about to start here. Instead, I made el-patch-get (which also makes the variant argument optional) use the one and only variant present for the given name. If more than one variant is present, and the caller didn't supply variant, el-patch-get now signals an error. I picked wrong-type-argument because it was the standard error closest in spirit to what I was trying to convey, and I didn't feel that this case called for defining a whole new error.

I make significant use of `el-patch-validate` non-interactively in my
init file.  These usages broke when I updated to the latest version of
el-patch, because an invocation that used to work such as

    (el-patch-validate 'some-function 'defun 'nomsg)

was now unable to look up the patch I had just applied to
`some-function`.  I believe this is happening because
`el-patch-validate` was allowing you to omit `variant`, and `nil` is
not a possible variant.  From reading the code, I believe all variants
will be a cons of `(advice name)`.  Therefore when `el-patch-validate`
calls `(el-patch-get 'some-function 'defun nil)`, it will never get a
result, and `el-patch-validate` will always fail.

`(nil)` *could* perhaps be called "the default variant", but I didn't
see it hard coded anywhere else in el-patch, so I wasn't about to
start here.  Instead, I made `el-patch-get` (which also makes the
`variant` argument optional) use the one and only variant present for
the given name.  If more than one variant is present, and the caller
didn't supply `variant`, `el-patch-get` now signals an error.  I
picked `wrong-type-argument` because it was the standard error closest
in spirit to what I was trying to convey, and I didn't feel that this
case called for defining a whole new error.
@raxod502
Copy link
Member

raxod502 commented Apr 6, 2023

Thanks. I think the problem here isn't quite that el-patch-variant needs to search the defined variants, but rather the internal hash structure was changed in #63 and el-patch-validate wasn't updated to use the new format. Does that sound right to you, @haji-ali?

@haji-ali
Copy link
Contributor

haji-ali commented Apr 9, 2023

Thanks @dsedivec for catching this bug.

As you and @raxod502 pointed out, el-patch-get should be updated to allow a traditional variant. I pushed 7dfbd37 which should address this and recover the old-behavior. Let me know if this resolves your issue.

@raxod502
Copy link
Member

Thank you! Will go ahead and close this as I think the issue is resolved by 7dfbd37.

@raxod502 raxod502 closed this Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants