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

Use cc-mode infrastructure throughout #66

Open
haxney opened this issue Jan 28, 2013 · 9 comments
Open

Use cc-mode infrastructure throughout #66

haxney opened this issue Jan 28, 2013 · 9 comments
Labels

Comments

@haxney
Copy link
Contributor

haxney commented Jan 28, 2013

Much of the existing functionality can be implemented in terms of c-lang-defconst calls at the top-level. These seem to have the advantage of handling both indentation and font-locking within the same declarations. This also allows more complete leverage of the powerful cc-mode libraries.

This supersedes #64.

@haxney
Copy link
Contributor Author

haxney commented Jan 28, 2013

BTW, I've started working on this.

@ejmr
Copy link
Collaborator

ejmr commented Jan 28, 2013

Good idea. Redefining the core of php-mode, particularly how we inform Emacs about the structure of the language, will make it easier to take advantage of things like customizable lineup functions in cc-mode. It also feels like a good direction to go in terms of making the codebase more consistent in structure. After all, php-mode is going on fourteen years now, and lots of people have worked on it, and we certainly haven't all been consistent in the way we've implemented things. And in all those years Elisp and standard libraries have improved as well, like ERT, things we ought to leverage in our favor. So I like this idea a lot, using more of cc-mode.

@haxney
Copy link
Contributor Author

haxney commented Feb 7, 2013

I'm getting closer! It seems like most fontification can be done with trivial
definitions of php-font-lock-keywords-*, which means the cc-mode machinery
is doing something right.

On my current branch, here are the definitions of the php-font-lock-keywords-*
variables:

(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php)
  "Basic highlighting for PHP mode.")

(defconst php-font-lock-keywords-2 (c-lang-const c-matchers-2 php)
  "Medium level highlighting for PHP mode.")

(defconst php-font-lock-keywords-3 (c-lang-const c-matchers-3 php)
  "Detailed highlighting for PHP mode.")

(defvar php-font-lock-keywords php-font-lock-keywords-3
  "Default expressions to highlight in PHP mode.")

Indentation still needs some work, but is mostly there.

@ejmr
Copy link
Collaborator

ejmr commented Feb 7, 2013

Awesome, thanks for the work. :)

@jorissteyn
Copy link
Contributor

After playing around with haxneys changes, I believe this is an excellent course of direction. I rerolled the original changes on current php-mode and made some fixes to make it pass the test suite.

In case anyone's interested: https://github.com/jorissteyn/php-mode/tree/work/ccmode

It seems to work really well, but I still have some fixes upcoming -- if only PHP had chosen :: as namespace separator :). Feedback is very welcome!

@ejmr
Copy link
Collaborator

ejmr commented Aug 28, 2014

Great submission :)

I pushed it in a new branch for people to test and mentioned that in the README.

Thanks for the effort!

@jorissteyn
Copy link
Contributor

Great idea to mention this experiment in the README, but if it's not on master, the only people who will read it are the people that already know about it :)

@ejmr
Copy link
Collaborator

ejmr commented Aug 31, 2014

Great point. I'm in such a habit of looking at all the different branches that people not doing that honestly didn't cross my mind at the time. I've copied the mention into the README on the master branch.

@jorissteyn
Copy link
Contributor

As discussed in PR #168, the hard require 'cl I added to get this branch pass CI is bogus. It should work with:

(unless (require 'cl-lib nil t)
   (require 'cl))

But I don't know what difference between master and the cc-mode branch causes this, I'm not calling set-difference anywhere in php-mode/php-mode-test.

Error output: https://travis-ci.org/jorissteyn/php-mode/jobs/34121887

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

No branches or pull requests

3 participants