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

Ligature Request: =~ and !~ #293

Closed
sos4nt opened this issue Oct 21, 2016 · 6 comments
Closed

Ligature Request: =~ and !~ #293

sos4nt opened this issue Oct 21, 2016 · 6 comments

Comments

@sos4nt
Copy link

sos4nt commented Oct 21, 2016

In Ruby and Perl there is =~ to match a pattern (regex) and !~ to not match a pattern:

"foo" =~ /o/
"foo" !~ /o/

It would be nice to have ligatures for both of these operators.

I propose the almost equals sign and the not almost equals sign:

"foo"  /o/
"foo"  /o/

(Adjusted for width, of course)

Regarding #167 (export PATH=~/.local/bin:$PATH) – I thinks it's safe to "activate" these ligatures only when there is whitespace around them (which is the idiomatic way to write the operators in both, Ruby and Perl): X =~ Y would trigger, X=~Y would not.

@joffrey-bion
Copy link

These ligatures seem pretty invasive to me. They completely change the perception of the actual operator which has a specific meaning in these languages. I think readers would get confused when seeing them, but that's just my personal opinion.

@Drenmi
Copy link

Drenmi commented Dec 22, 2016

Another option, which would preserve the distinct parts of the original operators:

foo ≅ /o/
foo ≇ /o/

@Crissov
Copy link

Crissov commented Jul 8, 2017

Where the tilde is used for the home directory it is almost always immediately followed by a slash. This could have been used to suppress the ligature and thus handle #167. Regular expressions are also often enclosed by slashes, but there usually is a space before the leading slash.

@Drenmi's suggestion of an elongated or centered U+2245 ≅ for =~ seems sound, but for !~ I'd rather expect something like U+2249 ≉ instead of U+2247 ≇, U+2246 ≆ or U+2244 ≄. There does not seem to be a precomposed character in Unicode of a single tilde with diagonal strike-through.

On second thought, ~= consitutes a precedent. It is rendered as an elongated U+2243 ≃ currently, so =~ could also become an elongated U+2242 ≂.

@tonsky
Copy link
Owner

tonsky commented Jul 8, 2017

but there usually is a space before the leading slash

I can’t rely on this sort of heuristic. It won’t work too often and users will end up with some magic replacement that sometimes works but sometimes does not. That increases confusion, and Fira Code goal always was to decrease confusion.

@daurnimator
Copy link

Sometimes ~ is an unary operator; or used as a home directory.
e.g. I wouldn't want this to render differently:

PATH=~/.local/bin:"$PATH"

Nor this lua 5.3 code (where ~ is unary bitwise NOT):

foo=~bar

@tonsky tonsky added this to the 3 milestone Apr 5, 2020
@tonsky tonsky closed this as completed in d8eef58 Apr 5, 2020
@tonsky
Copy link
Owner

tonsky commented Apr 5, 2020

Added to ss07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants