Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top