views:

407

answers:

1

I keep getting this error and similar errors while using php-mode on Emacs23 on Ubuntu:

Debugger entered--Lisp error: (void-function php-template-if-hook)
  php-template-if-hook()
  abbrev-insert(if #("if" 0 2 (fontified t face font-lock-keyword-face)) 414 416)
  #[(G73404 funs global) "[Byte Code]"
  apply(#[(G73404 funs global "[Byte Code]"
  (lambda (&rest --cl-rest--) (apply #[... "[Byte Code]"
  expand-abbrev()
  self-insert-command(1)
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)

when I type if(, and the error below when I type array( or anything that ends with array(, e.g. is_array(:

Debugger entered--Lisp error: (void-function php-template-if-hook)
  php-template-if-hook()
  abbrev-insert(if #("if" 0 2 (fontified t face font-lock-keyword-face)) 414 416)
  #[(G73404 funs global) "[Byte code]"
  apply(#[(G73404 funs global "[Byte Code]"
  (lambda (&rest --cl-rest--) (apply #[... "[Byte Code]"
  expand-abbrev()
  self-insert-command(1)
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)

This error is raised even when I use the emacs starter kit. Anyone fixed a similar problem?

The php-mode.el I use is from the emacs starter kit which bundles a version of nxhtml. I tried using php-mode-1.5.0 still no success. I even tried using the latest version of nxhtml(2.2), but still the same error persisted. I had to copy and paste all the function definitions missing from mewde for it to work with relative sanity. I have to say that it does add some value though. :)

The funny thing, this problems seems to be an Ubuntu Karmic only problem for me, I was using the same stuff on the emacs on opensuse 11.0 and 11.1 without a single problem.

Thanks.

+1  A: 

The problem is that something is trying to call the undefined function 'php-template-if-hook.

It'd be useful if you provided a link to where you found the php-mode.el you are using, because there seem to be several.

The symbol 'php-template-if-hook is not a part of the php-mode.el on sourceforge, so you either have a different version, or there's something else in your .emacs that's causing the problem. It looks as though something is triggering an abbrev insertion that leads to 'php-template-if-hook. Note: it looks like people on stack overflow are using the php-mode from sourceforge, so I'd recommend moving to that one.

A quick google search finds this php-mode.el, which defined 'php-template-if-hook to be:

(defun php-template-if ()
  "Insert an if statement."
  (interactive)
  (let ((start (point)))
    (insert "if ")
    (insert "(") ; +
    (when (php-template-field "condition" nil t start (point))
      (insert ") {") ; +
      (newline-and-indent)
      (setq start (point-marker))
      (insert "\n}")
      (php-indent-line-2)
      (goto-char start))))

But, solving your problem by cutting/pasting random code from the intertubes is not a good long-term solution.

Trey Jackson
I have updated the question with the necessary information. I have since merged the php-mode.el that I have with one that has all those functions defined and it seems to work fine so far, with a few problems here and there. What I don't know, is why I seem to be the only one having this problem, even with emacs22, and it's only in Ubuntu Karmic, I was using the same stuff on the emacs on opensuse 11.0 and 11.1 without a single problem.
partoa
Chances are, the Emacs you were using on opensuse had different stuff bundled with it. The original error was because a function wasn't defined. It isn't a part of Emacs (regardless of the OS), so there were different supporting libraries somebody had installed on the two systems.
Trey Jackson
I suppose. I even tried changing the cc-mode with the one from source forge to see what happens, still the same error recurred. I'm not well versed with Elisp otherwise I'd have opted to debug the underlying system instead, so it doesn't have to call an undefined function, or it doesn't throw an error at that, as was the case with opensuse. Anywayz, the problem is now fixed. Thanks for your response.
partoa