Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 230009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:48:49+00:00 2026-05-11T19:48:49+00:00

I am using Emacs 23 and php-mode.el 1.5.0. When I have this in my

  • 0

I am using Emacs 23 and php-mode.el 1.5.0. When I have this in my .emacs:

(require 'php-mode)

I get this error message when Emacs starts:

Warning (initialization): An error occurred while loading `/Users/kdj/.emacs’:

error: `c-lang-defconst’ must be used in a file

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `–debug-init’ option to view a complete error backtrace.

If I evaluate (require 'php-mode) after Emacs starts, I don’t get any error messages.

I found a blog entry which indicates that this problem is specific to Emacs 23 (that is, there is no error with Emacs 22.x), but it doesn’t give any solutions.

I don’t know if this matters, but I’m using Mac OS X, and I built Emacs from the current CVS sources, using ./configure --with-ns.

What’s going on here, and/or how I can fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:48:49+00:00Added an answer on May 11, 2026 at 7:48 pm

    I ran into the same problem when trying to get the csharp-mode up and running. I finally found the solution when digging into the actual Emacs Lisp file for csharp-mode:

    ;;   This code doesn't seem to work when you compile it, then
    ;;   load/require in the Emacs file. You will get an error (error
    ;;   "`c-lang-defconst' must be used in a file") which happens because
    ;;   cc-mode doesn't think it is in a buffer while loading directly
    ;;   from the init. However, if you call it based on a file extension,
    ;;   it works properly. Interestingly enough, this doesn't happen if
    ;;   you don't byte-compile cc-mode.
    

    So, the quick and dirty fix to put in your .emacs is to auto load on extension and not put (require 'php-mode) or (load "php-mode") in there. Without further ado,

    (autoload 'php-mode "php-mode" "Major mode for editing php code." t)
    (add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
    (add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
    

    I hope this helps! Now I just need to get the PHP/HTML mode switching stuff working. Wish me luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using emacs org-mode recently to maintain my TODO lists. I have
I am using emacs 22.2.1 and Ubuntu 9.04 I have done this in my
I have emacs 23.3.1, running on windows. php-mode 1.5 from http://php-mode.sourceforge.net/ , Modified: 2008-11-04
I am using emacs 24 on Windows 7 and have installed technomancy's clojure-mode along
I'm using emacs tramp mode to remotely edit files over ssh. The problem is
I am now using Emacs 23 with visual-line-mode turned of for text editing but
I'm using Emacs with clojure mode and slime connected to a swank server produced
Is there a good php syntax highlighter for Emacs? I'm using Emacs 23. I've
When I was using emacs with the auctex plugin, there was a mode called
I am using emacs on MacOS 10.6 with Terminal. I have a white background.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.