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

Improve detection of English contractions and other use of single quotes #322

Merged
merged 1 commit into from Jan 6, 2016

Conversation

eht16
Copy link
Member

@eht16 eht16 commented Jan 2, 2016

Temporarily add ' (single quote) to WORDCHARS to be able to parse
whole words containing a single quote (like doesn't and similar in English).

Closes #320.

Temporarily add ' (single quote) to WORDCHARS to be able to parse
whole words containing a single quote (like doesn't and similar in English).

Closes geany#320.
scintilla_send_message(doc->editor->sci, SCI_GETWORDCHARS, 0, (sptr_t)wordchars_orig);
if (! strchr(wordchars_orig, '\''))
{
GString *wordchars_new = g_string_new(wordchars_orig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on whether it's a hot spot, you could also simply add the ' to the orig string and truncate the last byte afterward (instead of copying the string)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, nice idea. What exactly do you mean by "whether it's a hot spot"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether the code is "hot" (called often), so basically whether optimizing this is worth the (trivial) added subtlety.

@b4n
Copy link
Member

b4n commented Jan 2, 2016

LGTM, but if people use and stuff like that. But I guess fully correct word boundary recognition requires a clever library like Pango or whatever, and it's tricky; so I guess adding ' is good enough at least for now.

@eht16
Copy link
Member Author

eht16 commented Jan 2, 2016

Yes, when anything else is used for contractions/short forms than a single quote, it will fail. Though, to my knowledge, this also would not correct English then anymore.
Also, in English as well as in German and maybe other languages as well, the single quote is used for things like "John Doe's shoes" and I guess using any other character than a single quote is not valid then.

@b4n
Copy link
Member

b4n commented Jan 3, 2016

is the typographic apostrophe, and is technically valid (and even more accurate) than the typewriter one '. But in practice it's less likely to be encountered in Geany I guess, because ' is more common outside typesetting programs.

frlan added a commit that referenced this pull request Jan 6, 2016
Improve detection of English contractions and other use of single quotes
@frlan frlan merged commit 4a77ba2 into geany:master Jan 6, 2016
@eht16 eht16 deleted the 320_fix_single_quote_detection branch February 7, 2016 15:28
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.

None yet

3 participants