开发者

how to add php mode hooks in emacs

I have a emacs mode hoo开发者_如何学Gok code

(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))))))

I need to ensure to call this function whenever i open a php file within emacs.. i have installed php-mode for emacs as well as added this code in .emacs file but it seems not to be working.. can anyone tell me how to add such customization code for emacs?

NOTE: I have recently migrated to emacs.. please be more descriptive while answering.. :)

Updated code1

(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)))))))


Adding hooks to places provided by various modes usually works using the add-hook function. You defined a function with the name of the hook you wanted to use. Instead, you should define a function with another name, add add-hook that to the php-mode-hook:

(defun my-php-settings ()
  ...)

(add-hook 'php-mode-hook 'my-php-settings)

In fact, you don't even need to create a named function at all:

(add-hook 'php-mode-hook
          (lambda ()
            (setq tab-width 4 ...)))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜