我很新emacs
,我認爲這將是很好,如果你分享你的日常php工作中使用的配置。讓我們分享我們的emacs php配置
6
A
回答
3
這足以讓我,基於Kohana的一些項目剛剛縮進規則:
(add-hook 'php-mode-hook
(lambda()
(c-set-style "bsd")
(setq c-indent-level 2)
(setq c-continued-statement-offset 2)
(setq c-brace-offset -2)
(setq c-argdecl-indent 0)
(setq c-label-offset -2)
(setq c-basic-offset 2)
(setq tab-width 2)
(setq indent-tabs-mode nil)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-close 'c-lineup-arglist-operators)
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math)))
1
我舉一些這方面從drupal.org Emacs的配置討論。我注意到有人在那裏發佈了一個合適的衍生drupal模式,但我沒有到處去改變我的配置。
你會注意到其中的一些被註釋掉了。我最近沒有看過這些,所以我只是逐字地發佈它。
我-programming.el(由我的init.el文件要求)
;; nXHTML
(load "nxhtml/autostart.el")
;; ...
;; PHP (see my-php.el)
(autoload 'php-mode "my-php" "PHP Mode." t)
(add-to-list 'auto-mode-alist '("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))
;; Drupal mode
(autoload 'drupal-mode "my-php" "Drupal Mode." t)
(add-to-list 'auto-mode-alist '("\\.\\(module\\|test\\|install\\|theme\\)\\'" . drupal-mode))
(add-to-list 'auto-mode-alist '("/drupal.*\\.\\(php\\|inc\\)\\'" . drupal-mode))
(add-to-list 'auto-mode-alist '("\\.info\\'" . conf-windows-mode))
我-php.el:
;; n.b. php-mode is the modified version provided by nxhtml
;; at: lisp/nxhtml/related/php-mode.el. lisp/nxhtml/related
;; was added to the load path by nxhtml/autostart.el (which
;; is loaded in my-programming.el prior to defining the PHP
;; autoloads).
(load "php-mode") ;load the real php-mode
;; Custom php-mode configuration
(add-hook 'php-mode-hook 'my-php-mode)
(defconst my-php-style
'((c-offsets-alist . ((arglist-close . c-lineup-close-paren))))
"My PHP programming style")
(c-add-style "my-php-style" my-php-style)
;; Configure imenu usage with php-imenu (also provided by nxhtml)
(autoload 'php-imenu-create-index "php-imenu" nil t)
(defun my-php-mode()
"My php-mode customisations."
(c-set-style "my-php-style")
;; The electric flag (toggled by `c-toggle-electric-state').
;; If t, electric actions (like automatic reindentation, and (if
;; c-auto-newline is also set) auto newlining) will happen when an
;; electric key like `{' is pressed (or an electric keyword like
;; `else').
(setq c-electric-flag nil)
;; electric behaviours appear to be bad/unwanted in php-mode
;; This is bugging out recently. Not sure why. Thought it
;; was a conflict with (my-coding-config), but not certain
;; any longer. Commenting out for now.
;; Configure imenu
;; (php-imenu-setup)
;; Find documentation online
(local-set-key (kbd "<f1>") 'my-php-symbol-lookup))
(defun php-imenu-setup()
(setq imenu-create-index-function (function php-imenu-create-index))
;; uncomment if you prefer speedbar:
;;(setq php-imenu-alist-postprocessor (function reverse))
(imenu-add-menubar-index))
(defun my-php-symbol-lookup()
"Find the symbol at point in the online PHP documentation."
(interactive)
(let ((symbol (symbol-at-point)))
(if (not symbol)
(message "No symbol at point.")
(browse-url (concat "http://php.net/manual-lookup.php?pattern="
(symbol-name symbol))))))
(defun drupal-mode()
"PHP mode configured for Drupal development."
(interactive)
(php-mode)
(message "Drupal mode activated.")
(set 'tab-width 2)
(set 'c-basic-offset 2)
(set 'indent-tabs-mode nil)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-intro '+) ; for FAPI arrays and DBTNG
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math) ; for DBTNG fields and values
;; Don't clobber (too badly) doxygen comments when using fill-paragraph
(setq paragraph-start (concat paragraph-start "\\| \\* @[a-z]+")
paragraph-separate "$"))
1
相關問題
- 1. javascript:讓我們分享控制
- 2. VM不會讓我們分配**字節
- 3. VM不會讓我們分配...字節
- 4. 讓我們和內存分配
- 5. defn vs讓我們分解
- 6. 我們可以分享GooglePlus_ClientID和GoogkePlus_simpleAPI_key嗎?
- 7. 我們如何配置租戶之間的資源共享?
- 8. Google+的API讓人們「我」
- 9. 我們給出一個數字讓我們說米。我們必須將該編號分成n份
- 10. iOS分享我們自己的位置給其他人?
- 11. 分享我們的源代碼控制多個位置
- 12. 我們可以讓Emacs找到變量的定義嗎?
- 13. 我們如何從共享內存中分配動態內存?
- 14. Apple如何讓我們設置我們的表格視圖單元格?
- 15. SLComposeViewController - 讓他們分享他們通過Facebook玩遊戲只讀
- 16. ViewPager錯誤(VM不會讓我們分配)
- 17. 讓我們使cell.textLabel更短
- 18. 讓我們來談談struct
- 19. 如何配置SonarQube讓我們增加覆蓋範圍?
- 20. 我們可以配置simple-xml讓它忽略未知節點
- 21. 我們可以讓Emacs緩衝區爲靜態/固定?
- 22. 我們可以分配日期到UIDatePicker
- 23. 我們如何在openbravo中配置jsf
- 24. 我們如何配置grails shiro plugin v1.1.3?
- 25. 我們可以配置在詹金斯
- 26. 我們如何跟蹤我們的工作副本的分支?
- 27. 讓我們與Clojure的綁定
- 28. 我們有HttpHandlers的PHP中,我們在ASP.Net
- 29. 我們應該在我們的webapp上使用Pylons還是PHP?
- 30. 如何整合聯繫我們部分在我們的網站?
爲什麼它被視爲「offtopic」?配置方面非常接近開發本身,某種好的/最佳實踐,imho。不是嗎? – zerkms 2010-09-22 06:45:40
這個問題不應該被低估。也許這個問題可能會被重新修改一下,因爲我認爲沒有多少人只使用PHP配置emacs。但是,如果沒有評論就會降低這個問題,這只是粗魯。 – ocodo 2010-09-22 06:48:21
如何改寫?移動到一般配置沒有PHP的具體細節? – zerkms 2010-09-22 06:55:35