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

Cleanup variable usage #441

Merged
merged 14 commits into from
Feb 16, 2021
Merged

Conversation

clemera
Copy link
Collaborator

@clemera clemera commented Feb 15, 2021

No description provided.

selectrum.el Outdated
@@ -88,6 +75,11 @@ See `minibuffer-default-in-prompt-regexps', from which this is derived.")
:prefix "selectrum-"
:link '(url-link "https://github.com/raxod502/selectrum"))

(defcustom selectrum-should-sort-p t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be a defcustom? I think most of the variables which are supposed to be locally tuned in the minibuffer-with-setup-hook should be defvar-local. The same applies to selectrum--move-default-candidate for example. Is this global for legacy reasons? Then I would probably keep it as a defvar, add a comment that this variable is to be deprecated. And later on deprecate the variable, replacing it by a local variant. At the same time one could get rid of the -p suffix which goes against the elisp style guide.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be a defcustom the variables are able to be set locally but first and foremost are meant as user options. The name is problematic but I would prefer to avoid inconveniences for this reasons

Copy link
Contributor

@minad minad Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I am only asking for this reason - if it is really intended as a user option, fine! But I still have my doubts that it is useful as a global user option. Same applies to selectrum-move-default-candidate, which you will probably make public at some point (#333).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know about users which want to be able to disable sort by default that is why I think it should be an user option. For selectrum-move-default-candidate, I don't think it should be an option as its meant for session configuration.

selectrum.el Outdated

(defvar selectrum--candidates-overlay nil
"Overlay used to display current candidates.")

(defvar selectrum--dynamic-candidates nil
(defvar selectrum--count-overlay nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overlay could also be local since it is tied to a specific recursive minibuffer session I suppose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May apply to both overlays? candidates and count?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use move-overlay it shouldn't be set locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably looked at the old version? This PR handles them both equally

Copy link
Contributor

@minad minad Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I have seen the move-overlay, I have only a superficial picture here. But this does not sound like a good design decision. Overlays are tied to a buffer (see the function overlay-buffer). When going into minibuffer recursion it is probably better to create a separate overlay for each minibuffer buffer. I am also using buffer-local overlays in Consult and that approach seems to work well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icomplete seems to also have this updating bug btw. Probably for the same reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could add to the README comparison list - Selectrum handles recursive sessions properly ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems likely now. I don't often use recursive sessions that is why I never observed it I guess. So this is a clear win for your isolation argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With recursive sessions I feel it would be much nicer if Emacs would behave like embark-become and simply close the other session. I'm always annoyed when doing something in a recursive session (like opening help buffer from drescribe-function) only to see it closed when exiting the session...

Copy link
Contributor

@minad minad Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, but then it wouldn't be recursive ;) But I am also not entirely convinced by recursive editing. For example with consult-line one can jump out of the minibuffer, do some editing and jump back. If that's useful or not 🤷‍♂️

@clemera clemera force-pushed the cleanup-variable-usage branch 2 times, most recently from 1542ae9 to a8b6617 Compare February 15, 2021 17:54
@clemera
Copy link
Collaborator Author

clemera commented Feb 15, 2021

@minad Added selectrum-move-default-candidate now in this PR, too. You can update consult and after a while I will remove the private one like last time.

@minad
Copy link
Contributor

minad commented Feb 15, 2021

Okay, cool. I will push the update soon!

@minad
Copy link
Contributor

minad commented Feb 15, 2021

From my side it is okay if you remove the private variable right away. I will push the update as soon as you merge this such that we are in sync. Even if someone uses selectrum/consult out of sync, there won't be big issues when consult sets a non-existing private variable. I mean this is only a superficial ui issue.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I saw you renamed the sort variable. Do you also plan to rename the other -p variables? There is at least selectrum-active-p which is also public API. Then there are a few more internal ones like selectrum--crm-p.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

Thanks! I am not a fan of the -is-foo convention, but this seems to be what the elisp style guide recommends. At least better than -p. And sorry if I interrupted you too early given that you already made this change 😄

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

No problem originally I wouldn't have renamed all of them here but why not better to be consistent right away. BTW is there some convention at what time removing deprecated aliases is okay?

I am not a fan of the -is-foo convention

Do you use something else?

@minad
Copy link
Contributor

minad commented Feb 16, 2021

No problem originally I wouldn't have renamed all of them here but why not better to be consistent right away. BTW is there some convention at what time removing deprecated aliases is okay?

I don't think there is a commonly accepted guideline. My suggestion would be to deprecate everything in 3.1 and depending on how things go either publish a 3.2, 3.3 or go directly to 4.0, where you remove all the deprecations. This means the removal is not based on time but on the version, which is maybe not the best way given that versions are handled cavalierly in the Emacs ecosystem, e.g. MELPA. However since there are also no dependencies on Selectrum in MELPA, I think it would be okay to do this. There are only few end users who are using the Selectrum APIs directly and I think they are following the project closely.

Do you use something else?

I usually avoid such meaningless words like is which only make the variable longer and would write selectrum-active. But this does not seem to be the style sanctioned by the elisp guide 😆

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

to deprecate everything in 3.1

I already deprecated them here for 3.0, I will probably remove then in 4.0 then I don't plan to do intermediate releases as I'm to lazy for that ;)

I usually avoid such meaningless words like is which only make the variable longer and would write selectrum-active. But this does not seem to be the style sanctioned by the elisp guide

Hm for me the main benefit is to quickly identify them as a flag but I agree that usually it is not necessary. I will probably use the is whenever it fits nicely into the name.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I already deprecated them here for 3.0, I will probably remove then in 4.0 then I don't plan to do intermediate releases as I'm to lazy for that ;)

Yes. What I meant is that the current version is 3.1-devel or something like this, since 3.0 has been released. My suggestion would be to tag a stable 3.1 release soon. And just before tagging the 4.0 version, remove all the deprecations. If the next version is directly 4.0 you will have the deprecations around much longer. So from the laziness point of view there is no difference, you just call the next version 3.1 instead of 4.0.

But it seems there haven't been any 1.2 etc releases in Selectrum so in the end it does not really matter. Selectrum seems to be using the versioning style where the major version is incremented quickly, which I am personally not fond of. For example I would consider the version 1.0 the first "really stable" version. But Selectrum is already 3.0 while I would rather consider it to be 0.13 or something like that, given the many internal significant changes you made recently and given how young the project is. Maybe after having reworked all the internals as you did now, I feel the library is much closer to my perceived 1.0 now ;)

Hm for me the main benefit is to quickly identify them as a flag but I agree that usually it is not necessary. I will probably use the is whenever it fits nicely into the name.

The elisp style guide seems to agree with you. I think it is okay.

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

With my own projects I also tend do wait much longer before an 1.0 release but I have never been into serious versioning until now hence also my hesitation to dealt with it, it's not just about tagging I also need to copy things (changelog/releasepage) around ;) I don't understand what you mean by having the deprecations around longer, I thought I would just tag the 4.0 release and remove the deprecations at the same time.

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

I think I get your point now: From a release standpoint the depreactions where never within a official release so when this is an requirement there would have to be an intermediate release.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I think I get your point now: From a release standpoint the depreactions where never within a official release so when this is an requirement there would have to be an intermediate release.

Exactly.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I see it as follows - the current master branch is still somehow 3.0 release compatible. This means if you release 3.1 with the deprecations, things are still fine and stable users would get warnings. After that the next 4.0 release would then break things. But given that nobody really relies on the versions here, it will be fine either way. You can even kick out stuff without deprecations without many people noticing, but it is just not a good style ;)

In Consult since I am still on version 0.5, I am moving things around from time to time until I reach 1.0. But I try to make it a bit carefully and also introduce deprecations if I see fit. I am also releasing rather often, since I don't care if I end up with versions like 0.13 after a while. At that point I can then make a 1.0 release out of it.

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

This sounds good to me, as I said I'm not very familiar with this process and I don't really know how to do what you are suggesting. I understand that I can tag a past commit as 3.1 but how do I get the depreacations in there?

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I would not backport any deprecations, I would do it the lazy way. Let's not bother with this too much now. I suggest you continue as is - I guess there are more deprecations incoming (if we go forward for example with hiding selectrum--read). After having done all this, adapt the changelogs etc and tag the current commit as 3.1.

If you want you can also tag some of the next commits as 3.1, and then add more deprecations afterwards. Then later on tag a commit as 3.2. And then just before tagging the 4.0 commit remove all the deprecations. That would also be fine. I don't think there is any magic with the versioning/release process. I would release more often with smaller increments and drop the deprecations when doing the major bumps. That's all.

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

The problem I see with that is that there are already breaking changes on master so using SemVer the next version should be 4.0 as I understand it. Thanks for your help with this!

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

I reread your comment above and you are right that it is somewhat compatible, maybe I should do just that.

@clemera clemera merged commit f68a63e into radian-software:master Feb 16, 2021
@minad
Copy link
Contributor

minad commented Feb 16, 2021

Agree, I just checked the changelog and would probably take a relaxed stance regarding the current changes. I think making the next version 3.1 is fine.

@minad
Copy link
Contributor

minad commented Feb 16, 2021

I just saw - the readme still mentions this save-global-state macro.

@clemera
Copy link
Collaborator Author

clemera commented Feb 16, 2021

Thanks, fixed by 1ba7c3f

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.

2 participants