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

The great font lock fixup #12

Merged
merged 1 commit into from
Feb 15, 2014
Merged

The great font lock fixup #12

merged 1 commit into from
Feb 15, 2014

Conversation

swsnr
Copy link
Contributor

@swsnr swsnr commented Aug 19, 2013

I dedicate this PR to fixing the font locking.

Currently, it just contains the relevant commit from puppetlabs/puppet-syntax-emacs#4 cherry-picked, to give us a basic start, but there is muuuuuuuuuch to do still.

I ignored puppetlabs/puppet-syntax-emacs#8, for it's the wrong fix imho. The culprit is not ordering, it's the lack of symbol boundaries in the keyword regexp.

Essentially each single regexp should be reviewed, ported to rx, using symbol-start and symbol-end at the right places, and as much syntax as possible.

The string regexp is probably superfluous, since we having syntactic fontification. However, we should highlight variable references in strings, just like Ruby does. Let's have a look at ruby-mode for this one.

Gonna start tomorrow evening, in the mean time, feel free to comment, @bbatsov.

Use regexp-opt to generate the regex to match keywords instead of
building it up by hand. The generated regex should be more efficient
than just combining all the keywords with "\\|".
@swsnr
Copy link
Contributor Author

swsnr commented Aug 19, 2013

@bbatsov Btw, can we “unfork” somehow? Imho we won't ever contribute back to the old repo anyhow, so technically, we aren't a fork in the best Github sense anymore, and Github starts to get in our way. For instance, it wanted to open this PR against the old repo…

Probably contact staff?

@bbatsov
Copy link
Contributor

bbatsov commented Aug 19, 2013

Sure we can - just delete this repo and from GitHub and create it again from your local git repo.

@swsnr
Copy link
Contributor Author

swsnr commented Aug 19, 2013

Won't that delete all issues?

@bbatsov
Copy link
Contributor

bbatsov commented Aug 19, 2013

Unfortunately - yes. I didn't think about that. Maybe contacting the support is the best option at this point (or maybe the issues to be exported somehow?).

As for the PR itself - some of the keywords are actually built-in functions that should be highlighted with font-lock-built-in-face IMO. I think that in Puppet lingo reserved word is the equivalent of keyword.

Btw, we haven't worked on that much issues yet, so it might not be the worst idea. I've googled a bit and it seems some people share our pain and a clean repo import is only way to solve the problem...

@swsnr
Copy link
Contributor Author

swsnr commented Aug 20, 2013

I'll contact support. If we don't get a response in a reasonable amount of time, we can still re-create the repository and migrate issues. It will be a lossy migration though, for while it is quite easy to get a complete list of issues from Github's API, it seems quite impossible to re-create them identically. For instance, you cannot for good reason create comments under another user's name via the API.

Concerning the keywords, I have not yet taken a close look at the current regular expressions. I am not convinced though, that cherry picking the commit was a good idea actually. I have rather resolved my mind to more or less start from scratch with the keywords. It's a mess currently, as anything in this mode.

I thought about writing a short Python script (or maybe refresh my little Ruby skills ;) ) to scrape Puppets documentation in order to obtain a complete list of reserved words and built-in functions. My intention is to write some ERT tests then to ensure that our font-lock keyword lists stays up to date, without us having to track Puppets documentation on each release.

@swsnr swsnr mentioned this pull request Aug 20, 2013
@swsnr
Copy link
Contributor Author

swsnr commented Aug 20, 2013

@bbatsov Github's support is truly awesome. This repo was detached not even ten minutes after writing to the support!

@bbatsov
Copy link
Contributor

bbatsov commented Aug 20, 2013

@lunaryorn Awesome. I honestly did not expect this :-)

@bbatsov
Copy link
Contributor

bbatsov commented Aug 20, 2013

Again on the subject of the PR - using a script to extract and verify keywords and built-in functions is a good idea. I personally prefer for us to do those in Ruby (for obvious reasons), but Python is an OK options as well.

@swsnr
Copy link
Contributor Author

swsnr commented Aug 20, 2013

@bbatsov I'll try Ruby then, and leave my feeble attempt to your mercy on the review ;)

@swsnr swsnr mentioned this pull request Aug 20, 2013
@apchamberlain
Copy link

I thought about writing a short Python script (or maybe refresh my little Ruby skills ;) ) to scrape Puppets documentation in order to obtain a complete list of reserved words and built-in functions.

Do you mean scraping the web site?

The web documentation at docs.puppetlabs.com is mostly dynamically generated directly from the Puppet source (via the puppet doc command), so you might as well go straight to the latter for the canonical list of reserved words.

@ghost ghost assigned swsnr Dec 26, 2013
bbatsov added a commit that referenced this pull request Feb 15, 2014
@bbatsov bbatsov merged commit 04589f7 into master Feb 15, 2014
@bbatsov bbatsov deleted the font-lock-fixup branch February 15, 2014 08:55
@bbatsov
Copy link
Contributor

bbatsov commented Feb 15, 2014

@lunaryorn I'll merge this, since it's an improvement of the code, anyways (and it'll fix #16).

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.

4 participants