English 中文(简体)
Emacs23 php-mode problem
原标题:

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.

最佳回答

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 "
}")
      (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.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签