Need for additional style guide - Use of free variables, unknown functions #69
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
help wanted
Extra attention is needed
I believe we are need of an additional style guide specific to Rational Emacs, which builds upon The Emacs Lisp Style Guide.
One item in particular is the use of dynamically bound variables (warned by the compiler as
free-variable
). Since we are forcing lexical binding (with the-*- lexical-binding: t; -*-
directive), the use of dynamically bound variables would actually be considered an error as opposed to a warning. Since this is typically does not effect the end result (Emacs still works), I consider it more of a style issue than anything else.The solution would be to use
(defvar somevar)
any place a dynamically bound variable (namedsomevar
) is used.An example from
early-init.el
would be:Where
native-comp-async-report-warings-errors
is dynamically bound.I'm suggesting the adoption of a style where one would do the following:
Another area where I think it would be proper to adopt a style is in the ensuring functions are declared in the context they are used. This could be handled by ensuring the appropriate module is
require
d in the context, or providing a declare-function statement before the function is used if it could be assumed to compiler would know about it ahead of time.An example here would be the use of
straight-use-package
. Assuming that we expect the Rational Emacs initialization to have occurred (which ensures thestraight
module is available), either a 'require' should be added:Or the 'declare-function' could be used:
I understand that Emacs is robust enough for this to "not matter", in the sense that "things will work" without this overhead. However there appears to be a mix of styles with regards to this and I think it would make sense for the project to define the style which should be used in order to provide some consistency.
The text was updated successfully, but these errors were encountered: