(defun php-mode-hook () (setq tab-width 4 c-basic-offset 4 c-hanging-comment-ender-p nil indent-tabs-mode (not (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name)) (string-match "\.php$" (buffer-file-name))))))
我已经为emacs安装了php模式,并在.emacs文件中添加了这段代码,但似乎不起作用。。有人能告诉我如何为emacs添加这样的定制代码吗?
注意:我最近迁移到emacs。。回答时请描述得更详细些。。:)
(add-hook 'php-mode-hook '(lambda() (setq tab-width 4 c-basic-offset 4 c-hanging-comment-ender-p nil indent-tabs-mode (not (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name)) (string-match "\.php$" (buffer-file-name)))))))
将钩子添加到各种模式提供的位置通常使用 add-hook 功能。您用要使用的钩子的名称定义了一个函数。相反,您应该使用另一个名称add来定义函数 添加挂钩 php-mode-hook :
add-hook
添加挂钩
php-mode-hook
(defun my-php-settings () ...) (add-hook 'php-mode-hook 'my-php-settings)
实际上,您甚至不需要创建命名函数:
(add-hook 'php-mode-hook (lambda () (setq tab-width 4 ...)))