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

Ensure turn-off-smartparens-mode also disables strict mode. #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wilfred
Copy link
Collaborator

@Wilfred Wilfred commented Nov 3, 2015

I've started using smartparens-strict-mode, and it works really well. However, I noticed my calls to turn-off-smartparens-mode didn't disable strict mode. This fixes that.

I think this is a reasonable behaviour, let me know what you think.

Wilfred added a commit to Wilfred/.emacs.d that referenced this pull request Nov 6, 2015
@Fuco1
Copy link
Owner

Fuco1 commented Nov 7, 2015

If we disable it like this then turning sp back on would not re-enable strict mode, which is what I would expect.

That is, if I enable strict mode for a buffer I would want smartparens-mode to disable it when I disable sp and enable it back when I enable it. I'm not sure how to solve this reliably.

@Wilfred
Copy link
Collaborator Author

Wilfred commented Nov 9, 2015

You're right, that'd be a little confusing. How about we add a turn-off-smartparens-strict-mode function? If users want both switched off, they can call both functions (it'd suit me at least).

I've modified my branch to add this command.

@Fuco1
Copy link
Owner

Fuco1 commented Nov 9, 2015

Is there, then, any reason not to call (smartparens-strict-mode -1). Or do you want it for hooks? Notice that calling this won't turn off smartparens-mode so you would need to call both "turn off" functions.

@Wilfred
Copy link
Collaborator Author

Wilfred commented Nov 12, 2015

Yep, exactly, I'd like it for hooks. I suppose I could call (smartparens-strict-mode -1) but we could say the same thing about turn-off-smartparens-mode. I like how explicit turn-off-smartparens-strict-mode is.

@Fuco1
Copy link
Owner

Fuco1 commented Nov 13, 2015

Maybe SP could have its own extra local variable which would track if the strict mode was on when sp was being disabled and re-enable it according to that.

So the situations will be:

  1. User turns both on. If a setting "track strict mode" is on, toggling SP also toggles strict mode (first time turning on strict mode means it is "on" for the buffer)
  2. User turns both on, but has "track strict mode" disabled. To disable both, they have to turn both off manually/on hook (like you propose)
  3. User doesn't use strict mode at all. Nothing special happens.
  4. User toggles strict mode on and then off, the "tracking variable" will set itself to off. Toggling SP on or off will leave strict mode off.

Since we have 2 modes with 2 states 4 situations should be all, unless I'm missing some sequence

@Wilfred
Copy link
Collaborator Author

Wilfred commented Nov 16, 2015

Hm, is it that complicated? Are there any situations where I'd want smartparens-strict-mode but not smartparens-mode?

I thought strict mode was just SP with a few extensions. I can't see any situation where I wouldn't want to switch one off without also wanting to switch the other off.

@Fuco1
Copy link
Owner

Fuco1 commented Nov 16, 2015

Right, the issue is more that if you had strict mode before and you toggle both off with just call to turn-off-smartparens-mode, calling turn-on-smartparens-mode (or just (smartparens-mode 1) should also re-enable strict mode.

You are right that it makes little sense having just strict mode on without SP. The reason it's a minor mode is to have the keymap with the remapping toggle-able.

@Fuco1
Copy link
Owner

Fuco1 commented Apr 3, 2024

I'm going to change the behaviour in the following way:

  1. If you turn on strict mode, it will automatically enable smartparens-mode if it wasn't already on
  2. If you turn off smartparens-mode, it will automatically disable strict mode which remaps a lot of regular commands to smartparens variants.

The other cases will do nothing special. If you first enable smartparens, then strict mode and then disable strict mode, it will only disable strict mode.

This way it behaves in a way that smartparens-mode is a "dependency" of strict mode, and disabling it will turn off both. Enabling just strict mode will enable the "dependency".

I will also deprecate the turn-off-smartparens-mode, I don't know why it exists to be hones... if someone needs it for a hook, they can just add a lambda or something. It seems pointless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants