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

treewide: replace (eq/equal foo nil) with (null foo) #1884

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

Hi-Angel
Copy link
Contributor

Just a trivial refactoring

@tomdl89
Copy link
Member

tomdl89 commented Apr 14, 2024

Thanks for the PR @Hi-Angel. In the interests of being technically correct (which is the point of this PR anyway!) I think most (all?) of these should use not rather than null. As the info page Predicates on Lists says about null:

This function is identical to not, but as a matter of clarity we use null when object is considered a list and not when it is considered a truth value…

and I think these are truth values rather than empty lists..?

@Hi-Angel
Copy link
Contributor Author

Sure, good point. Done!

@Hi-Angel Hi-Angel changed the title treewide: replace (eq/equal foo nil) with (null foo) treewide: replace (eq/equal foo nil) with (not foo) Apr 14, 2024
@axelf4
Copy link
Collaborator

axelf4 commented Apr 15, 2024

This function is identical to not, but as a matter of clarity we use null when object is considered a list and not when it is considered a truth value…

and I think these are truth values rather than empty lists..?

That is not true, in most of these cases nil is used as a stand-in for any other symbol, and not to indicate falseness.

@Hi-Angel
Copy link
Contributor Author

Well, the variables look like are truth values, i.e. not action, not repeat-type, not flag. The function calls may be not so much…

I'm okay with whatever. It's a purely stylistic matter, null is an alias to not. not is one character shorter. On the other hand, my Python habit makes me prefer null over not (in Python not is error-prone in places), but then again ELisp isn't Python 😊 So, yeah, at the end I'm okay with either choice.

@axelf4
Copy link
Collaborator

axelf4 commented Apr 15, 2024

Well, the variables look like are truth values, i.e. not action, not repeat-type, not flag.

action is one of nil for try-completion, t for all-completions, lambda for test-completion, metadata, (boundaries . ,suffix) for the type of completion action to perform, c.f. minibuffer.el which also uses (null action).

repeat-type is the repeat type and one of ignore, motion, abort, nil, ...

Neither is a boolean value.

((null action) is of course a truth value, but that does not mean not should have been used.)

@tomdl89
Copy link
Member

tomdl89 commented Apr 15, 2024

@axelf4 my focus was more on the first half of the sentence:

we use null when object is considered a list

which these are not. I interpreted the second half of the sentence to be non-exhaustive:

not when it is considered a truth value

i.e. not when it is considered a truth value, but also not when it is a stand-in for any other symbol, etc?

So do you think this PR is more correct with nulls than nots? I'm happy to defer to you on this, as I get the impression you're more of a proper lisper than me.

@tomdl89
Copy link
Member

tomdl89 commented Apr 15, 2024

Having read a bit more on this, I think @axelf4 is right, and the documentation is confusing. Sorry for the confusion @Hi-Angel

@Hi-Angel
Copy link
Contributor Author

It's okay, I made a backup branch for the case we decided to revert everything to the older version 😊

I'll take a closer look to see if anything looks potentially like a boolean value to have there not instead of null.

At the end of the day, (null foo) is stylistically equivalent to (eq/equal foo nil), because both cases explicitly compare to nil, so even replacing everything with null would imply no stylistic regression.

@tomdl89
Copy link
Member

tomdl89 commented Apr 15, 2024

The lack of clarity in the manual is reported here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70392
and fixed here: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29

@axelf4
Copy link
Collaborator

axelf4 commented Apr 15, 2024

The lack of clarity in the manual is reported here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70392
and fixed here: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29

Nice! I agree that the documentation was ambiguous - good to get that cleared up.

What matters IMO is just that the completion functions stay consistent with those in minibuffer.el (which use either (eq _ nil) or (null _)).

@Hi-Angel
Copy link
Contributor Author

Hi-Angel commented Apr 15, 2024

Okay, so, I looked through changed locations, and neither is a boolean value, i.e. they all take some symbolic values as well besides nil. So in the end I just reverted to the older version that replaces the pattern to (null …).

@Hi-Angel Hi-Angel changed the title treewide: replace (eq/equal foo nil) with (not foo) treewide: replace (eq/equal foo nil) with (null foo) Apr 15, 2024
@tomdl89 tomdl89 merged commit 95ee3ce into emacs-evil:master Apr 16, 2024
12 checks passed
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.

3 participants