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

Need two backslashes in regex string. #71

Merged
merged 1 commit into from
Aug 15, 2014
Merged

Need two backslashes in regex string. #71

merged 1 commit into from
Aug 15, 2014

Conversation

jimm
Copy link

@jimm jimm commented Aug 13, 2014

The auto-mode-alist regexes in emacs-mode.el all end with "'" (one backslash + single quote) but they need to end with "\'" (two backslashes + single quote).

The regexes are trying to match the empty string at the end of a regex (i.e., make sure that the file extension is at the end of the file name). Such a match is represented by either "$" or "'". However, inside an elisp string the backslash has to be escaped/doubled.

@bbatsov
Copy link
Contributor

bbatsov commented Aug 14, 2014

Yeah, you're right. I'm the one who made that mistake (keep making it all the time...).

Just a bit of clarification $ and \' are not the same - the first matches the end of line and the second matches the end of string (which is the one we want). Of course, as files rarely have multi-line names this is rarely an issue in practice.

@jimm
Copy link
Author

jimm commented Aug 14, 2014

Thanks for the clarification, Bozhidar. Even after reading the regex docs in Emacs Info I didn't see the difference.

I screw up escaping things in regexes all the time --- especially Emacs regexes.

mattdeboard added a commit that referenced this pull request Aug 15, 2014
Need two backslashes in regex string.
@mattdeboard mattdeboard merged commit 6ff1db2 into elixir-editors:master Aug 15, 2014
@mattdeboard
Copy link
Contributor

I'm generally opposed to "just in case" patches (re: @bbatsov 's original fix to the regex at issue here) but in this particular project I'm glad to have more eyes on the code. There is some puzzle-solving yet to be done wrt the grammar (see open issues) that is beyond my capability & bandwidth as a single person.

@jimm
Copy link
Author

jimm commented Aug 15, 2014

Thanks for accepting this patch.

I may try to take a look at some of the issues if I have time, but I'm not a guru when it comes to language mode code. I've seen other language modes have the same problems with quotes and character constants, too.

@mattdeboard
Copy link
Contributor

I think there is a general dearth of language mode gurus :P

@mattdeboard
Copy link
Contributor

...and in truth, the issue isn't the language mode stuff. At issue is the original implementation of SMIE. There is nothing exotic about Elixir's syntax (specifically, indentation rules). My instinct is that there's a couple small bugs or quirks in the original code that needs to get hammered out.

@jimm
Copy link
Author

jimm commented Aug 15, 2014

It seems like a few of the issues are because the question mark being treated as a character constant prefix inside comments and strings, when it shouldn't. Looks like there needs to be a check for not-in-comment and not-in-string in the function elixir-syntax-propertize.

Hmm...I'm glancing at the SMIE docs for the first time. "The parsing technique used by SMIE does not allow tokens to behave differently in different contexts." Looks like I have more reading to do.

@bbatsov
Copy link
Contributor

bbatsov commented Aug 15, 2014

I'm generally opposed to "just in case" patches

My absent-mindedness excluded the just in case approach is the one used by all built-in modes. This was the primary reason I suggested this - keeping in sync with the established practice.

I think there is a general dearth of language mode gurus :P

Don't think there was ever an abundance of those. :-) And we still have people like @dgutov (or ruby-mode and js2-mode fame) and @monnier (Emacs's maintainer and author of SMIE). Guess you can pick their brains for improvement suggestions.

Btw, SMIE differs in different Emacs versions. I know a lot of improvements were made in 24.4 (still unreleased), because more built-in modes adopted it.

@mattdeboard
Copy link
Contributor

👍

FWIW I have been in contact with @monnier over email, he gave me some good info

J3RN pushed a commit to J3RN/emacs-elixir that referenced this pull request Apr 24, 2021
Ensure debugger process continues to run, adapts to the new behavior in Elixir
1.9 that changed `Mix.Task.run` to return instead of sleeping indefinitely:
elixir-lang/elixir@3673849

- Fixes JakeBecker/elixir-ls#194
- Fixes JakeBecker/elixir-ls#185
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