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

Ability to highlight a pair's content #910

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

SamirHafez
Copy link
Contributor

@SamirHafez SamirHafez commented Jul 18, 2018

paren gives you an overlay that matches pairs and their content if you set its matching style to expression. smartparens doesn't support this matching style therefore there is no way to highlight the content of a pair.

In this PR I'm proposing a new customizable face sp-show-pair-match-content-face that will operate solely on the contents of a pair.

This has an advantage over the paren implementation as paren is too rigid in that it doesn't allow you to highlight pairs and their contents independently.

Here's a look at a possible configuration
kapture 2018-07-19 at 10 08 16

And a working scenario (should have used a more visible colour for this example :D)
kapture 2018-07-19 at 10 33 48

This content overlay relates to anything between the matching pair.
A new face `sp-show-pair-match-content-face` is available for customization.
@SamirHafez SamirHafez changed the title Added a content overlay Ability to highlight a pair's content Jul 18, 2018
@Fuco1
Copy link
Owner

Fuco1 commented Jul 19, 2018

I like how you implemented this, this way we can have both or neither or just the enclosing pairs.

Can you also edit the documentation https://github.com/Fuco1/smartparens/wiki/Show-smartparens-mode or do you need some special permissions for that? (In which case I can do that).

👍

@SamirHafez
Copy link
Contributor Author

@Fuco1 thanks.
Can't edit the wiki though, no permissions, sorry.

@Fuco1
Copy link
Owner

Fuco1 commented Jul 19, 2018

@SamirHafez OK, I'll leave this open until I fix the docs so that I won't forget. If it takes too much time feel free to poke me!

Otherwise LGTM.

@kqr
Copy link

kqr commented Jul 24, 2018

Maybe something like this, appended to the bottom of the existing page?

In addition, smartparens has a third face which is used for the expression between matching pairs. This face is named:

sp-show-pair-match-content-face

By default, show-smartparens-mode does not highlight the contained expression at all. Setting sp-show-pair-match-content-face to the same thing as sp-show-pair-match-face emulates setting show-paren-style to expression when using show-paren-mode.

However, it may also be useful to use a different colour for the matching pairs and the contained expression. This is of course possible with show-smartparens-mode but not with regular show-paren-mode.

@kqr
Copy link

kqr commented Jul 24, 2018

Sorry a bit tired so I realise it may have all been junk. Oh well, it didn't cost me anything!

Thank you, @SamirHafez for implementing this!

@Fuco1
Copy link
Owner

Fuco1 commented Jul 25, 2018

@kqr Why junk, I think it makes perfect sense. I'll copy the text there right away. Thanks for the contribution!

@Fuco1
Copy link
Owner

Fuco1 commented Jul 25, 2018

Ok, the docs are live https://github.com/Fuco1/smartparens/wiki/Show-smartparens-mode#customizing-the-looks so I'm merging this.

Thank you both for the work again!

@Fuco1 Fuco1 merged commit 7b36067 into Fuco1:master Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants