fix: resolve byte-compile warnings - #571
Open
dannywillems wants to merge 8 commits into
Open
Conversation
The byte-compiler in recent Emacs versions warns when a docstring contains a leading single quote that it cannot interpret as part of a `...' quoting pair. Escape these quotes with \=' so they render as intended in help buffers and no longer trigger warnings. For the docstrings generated by the `general-create-definer' macro, the quoted defaults (for example, :states 'insert) were interpolated verbatim. Escape leading single quotes in the formatted defaults string so the generated docstrings are also warning-free. This does not change how the text renders in the help buffer.
The docstring of `general--parse-def' had a line wider than the 80 character limit enforced by the byte-compiler. Rewrap it without changing the wording.
The `(declare (indent 1))' form preceded the docstring in `general-predicate-dispatch', so the byte-compiler treated the following string as a second doc string and warned. Move the declare form after the docstring, which is the expected position. The indent declaration is still applied.
Several functions are defined either inside a `general-with-eval-after-load' block (the use-package integration handlers) or at runtime by `general-evil-setup' via `general-create-definer' (general-imap and the other state definers). Because the byte-compiler does not see these definitions as top-level forms, it warned that the functions were not known to be defined where they are referenced. Add `declare-function' declarations for these functions. The declarations only inform the byte-compiler and do not change runtime behaviour; the functions are still defined exactly as before.
Add a dedicated workflow that byte-compiles and loads general.el on Emacs 28.2, 29.4, 30.1, and the snapshot build, installing the optional evil and use-package dependencies first. The build does not treat warnings as errors because general.el still emits a small number of warnings that cannot be fixed without changing behaviour or raising the minimum supported Emacs version. Also add a dependabot configuration to keep the GitHub Actions used by the workflows up to date.
Author
|
This is an automated effort to help maintaining packages in the Emacs community. See https://x.com/dwillems42/status/2060720730338185699 and https://dannywillems.github.io/emacs-package-maintenance/ |
The :key-type of the general-alist widget used (or symbol (repeat symbol)), but or is not a valid widget type. The byte-compiler reported "in define-widget for general-alist: or is not a valid type", and the widget would error if ever instantiated. The widget type that expresses "a symbol or a list of symbols" is choice, so replace or with choice. This is behaviour-preserving: the previous form was never a usable widget type.
cl-gensym is obsolete as of Emacs 31.1 (use gensym instead), which the byte-compiler reports for the two call sites in general-define-key and general-key-dispatch. The built-in gensym has existed since Emacs 26.1, but the package declares a 24.4 minimum, so a blind replacement would break on 24.4 and 25.x. Add a general--gensym defalias that resolves to gensym when available and falls back to cl-gensym only on Emacs older than 26.1. The fallback reference is wrapped in with-suppressed-warnings so the obsolete warning does not fire on Emacs 31.1+ (which always provide gensym and never take that branch). Behaviour is unchanged: both produce a fresh uninterned symbol from the same prefix.
Now that the residual byte-compile warnings are resolved, enable byte-compile-error-on-warn so the byte-compile workflow fails on any new warning across the matrix (Emacs 28.2, 29.4, 30.1, snapshot). The optional integration dependencies (evil, use-package) are already installed before compilation so their symbols are known to the byte-compiler.
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.
This pull request resolves the behaviour-preserving byte-compile
warnings emitted by
general.elon recent Emacs versions. Each warningtype is addressed in its own commit, and a CI workflow is added.
Fixes
quotes with
\='so they render as intended and no longer triggerwarnings. This also covers the docstrings generated by the
general-create-definermacro, whose interpolated quoted defaults(for example
:states 'insert) were flagged. The generated textrenders identically in help buffers.
general--parse-defwithout changing wording.general-predicate-dispatch, the(declare (indent 1))form preceded the docstring, so the compilertreated the docstring as a second one. Move
declareafter thedocstring; the indent declaration is still applied.
declare-functiondeclarations for functions defined inside the
general-with-eval-after-loaduse-package block and for the statedefiners created at runtime by
general-evil-setup. These arecompiler hints only and do not change runtime behaviour.
CI
Add a
byte-compileworkflow that byte-compiles and loadsgeneral.elon Emacs 28.2, 29.4, 30.1, and snapshot (installing the optional
eviland
use-packagedependencies). It does not use warnings-as-errorsbecause some warnings remain that cannot be fixed without changing
behaviour or raising the minimum supported Emacs version. A dependabot
configuration is added for the GitHub Actions.
Residual warnings (intentionally left out of scope)
in define-widget for general-alist: 'or' is not a valid type(line 162): changing the
:typewidget fromortochoicewouldalter the custom widget, which is a behaviour change.
cl-gensym is an obsolete function ... use gensym instead(twooccurrences): plain
gensymwas only added to core in Emacs 26.1,but the declared minimum is Emacs 24.4. Replacing
cl-gensymwouldraise the minimum supported version, so it is left unchanged.