Skip to content

php-mode executes c-mode hooks #407

@NateEag

Description

@NateEag

I recently added cquery to my c-mode setup, which meant adding a c-mode-hook to start cquery.

Doing that broke my ability to open PHP files sanely, because cquery starts itself before my lsp-php instance gets a chance to start, resulting in a broken state. Since they're both lsp-mode plugins, each targeting a specific language, it makes sense that they conflict.

I gather that php-mode is derived from c-mode, and therefore runs c-mode's hooks. I've worked around this problem by only starting cquery when (equal major-mode 'c-mode), but it doesn't seem like I should have to do that.

This StackOverflow question shows a similar problem and workaround.

The answer there points out that c-mode and friends actually derive from prog-mode, and suggests that php-mode should probably do that too. A quick search of cc-mode.el in Emacs 25.3.1 for define-derived-mode shows that is in fact how cc-mode.el currently does things.

I looked for any existing issues or discussion around this point, but I wasn't able to find any. I did find this thread with some discussion about the move to basing php-mode on cc-mode in the first place.

Should we consider extending prog-mode rather than c-mode?

If so, how much work would that involve?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions