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

underscores are not treated as word seperators #53

Closed
squid-lee opened this issue Jan 24, 2014 · 8 comments
Closed

underscores are not treated as word seperators #53

squid-lee opened this issue Jan 24, 2014 · 8 comments

Comments

@squid-lee
Copy link

(s-lower-camel-case "foo_bar") produces "foo_bar".
Expected Output is fooBar

(s-upper-camel-case "foo_bar") produces "foo_Bar".
Expected output is FooBar

I believe the fix is to replace underscores with spaces in the function s-split-words.

@magnars
Copy link
Owner

magnars commented Jan 24, 2014

(s-lower-camel-case "foo_bar") produces "fooBar" on my machine.

Could you try running the tests?

They contain this one, for instance:

 (defexamples s-lower-camel-case
    (s-lower-camel-case "some words") => "someWords"
    (s-lower-camel-case "dashed-words") => "dashedWords"
    (s-lower-camel-case "under_scored_words") => "underScoredWords")

@squid-lee
Copy link
Author

The tests ran fine. So I poked around a bit & it seems to be scala-mode2's scala-mode that causes it to not work.
I can take (s-lower-camel-case "foo_bar_") and it works differently in python-mode & scala-mode.

With a bit of 'emacs -q' and '(require 's)', it seems that this is the case even in vanilla emacs + s.el

@magnars
Copy link
Owner

magnars commented Jan 27, 2014

Ah, you're right. It's based on the current syntax definition.

That explains it. Not sure how to solve it, tho.

@squid-lee
Copy link
Author

Well I hacked it, and added '(replace-regexp-in-string "_" " " s)' instead of s in 's-split-words', but I imagine this might break in other places.

Where does the syntax definition factor in to things? I can't tell from looking in s.el or in the docs for split-string

@magnars
Copy link
Owner

magnars commented Jan 27, 2014

It's in s-split-words, using [:word:], [:lower:] and [:upper:] in
regexp to support all sorts of i18n issues. I guess _ is a word-character
in Scala.

On Mon, Jan 27, 2014 at 3:31 PM, MrBones118 notifications@github.comwrote:

Well I hacked it, and added '(replace-regexp-in-string "_" " " s)' instead
of s in 's-split-words', but I imagine this might break in other places.

Where does the syntax definition factor in to things? I can't tell from
looking in s.el or in the docs for split-string


Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-33371800
.

@squid-lee
Copy link
Author

Very well. I'll close it as an upstream problem. Thanks for the help

@magnars
Copy link
Owner

magnars commented Jan 27, 2014

Sorry about the lack of a solution.

@jaroslawr
Copy link

I ran into the same problem, and found a possible solution, there is (make-syntax-table) and a (with-syntax-table) macro, s.el could have its own syntax table derived from Emacs main syntax table, and wrap its functions with the with-syntax-table macro, making the results independent of the current syntax table:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Table-Functions.html

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 a pull request may close this issue.

3 participants