1

I need to unset the c-electric-flag and c-syntactic-indentation flags in Emacs23.4 when I open php files which name ends with .html.php, and only for that "name-pattern", because I use php-mode within html-mode and those flags indent the php code not in a proper way.

However, I would like to keep those flags on while editing pure .php files (php controllers, which contain only php source).

How can I do that?

4

1 回答 1

1

您可以通过检查 php-mode-hook 中的文件名来存档它,如果文件名与.html.php以下代码匹配,则禁用它们。

(defun my-php-mode-hook ()
  (when (and (buffer-file-name)
         (string-match-p "\\.html\\.php\\'" (buffer-file-name)))
    (c-toggle-electric-state -1)
    (setq c-syntactic-indentation nil)))
(add-hook 'php-mode-hook 'my-php-mode-hook)
于 2013-12-08T12:50:27.567 回答