handle package-version safely to prevent listp error#344
Merged
Wilfred merged 1 commit intoWilfred:masterfrom Jan 31, 2025
Merged
handle package-version safely to prevent listp error#344Wilfred merged 1 commit intoWilfred:masterfrom
package-version safely to prevent listp error#344Wilfred merged 1 commit intoWilfred:masterfrom
Conversation
When `package-version' is not what we expect (e.g a simple string), a `listp` error is thrown and you are unable to view the variable documentation due to it. This now handles it and provides a fallback value.
|
I just hit this also and fixed it like this, which I think is preferable as it still shows the package diff --git a/helpful.el b/helpful.el
index b9ee878..0e73383 100644
--- a/helpful.el
+++ b/helpful.el
@@ -1309,20 +1309,26 @@
"If SYM has version information, format and return it.
Return nil otherwise."
(when (symbolp sym)
- (let ((package-version
- (get sym 'custom-package-version))
- (emacs-version
- (get sym 'custom-version)))
- (cond
- (package-version
- (format
- "This variable was added, or its default value changed, in %s version %s."
- (car package-version)
- (cdr package-version)))
- (emacs-version
- (format
+ (string-join
+ (list
+ (when-let* ((package-version
+ (get sym 'custom-package-version)))
+ (pcase-let ((`(,package . ,version) (if (listp package-version)
+ package-version
+ `(,(file-name-base
+ (symbol-file sym))
+ .
+ ,package-version))))
+ (format
+ "This variable was added, or its default value changed, in %s version %s."
+ package
+ version)))
+ (when-let* ((emacs-version
+ (get sym 'custom-version)))
+ (format
"This variable was added, or its default value changed, in Emacs %s."
- emacs-version))))))
+ emacs-version)))
+ "\n\n")))
(defun helpful--library-path (library-name)
"Find the absolute path for the source of LIBRARY-NAME.
So feel free to use that instead of "unknown" for a nicer UX if you want |
Contributor
|
Please merge some version of this fix someone. |
Contributor
Author
I've merged elkens fix into my master branch |
Owner
|
Thanks :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
package-version' is not what we expect (e.g a simple string), alistp` error is thrown and you are unable to view the variable documentation due to it. This now handles it and provides a fallback value.This was a recurring problem I was facing when opening
which-keyvariables usinghelpful.which-keywould send a value of "31.0" and then cause this error:helpful--version-info: Wrong type argument: listp, "1.0"