Frage

Ich bin ziemlich neu in emacs und ich denke, es wäre schön, wenn Sie Ihre Konfiguration teilen, dass Sie in Ihrem täglichen php Arbeit.

War es hilfreich?

Lösung

, die für einige Projekt für mich, gerade Einzug Regeln genug basierend auf 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)))

Andere Tipps

Ich hob einige dieser von der Emacs-Konfiguration Diskussion über drupal.org. Ich merke, dass jemand einen richtigen abgeleiteten Drupal-Modus dort geschrieben, aber ich habe nicht an veränderten meine Config dazu gekommen.

Sie werden feststellen, dass einige dies für kommentiert ausgebrochen ist. Ich habe nicht in eine der, dass vor kurzem sah, so dass ich es wörtlich nur Entsendung bin.

my-programming.el (die durch meine init.el Datei erforderlich)

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

my-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 "$"))

Sie können meine Config überprüfen hier:

http://github.com/openist/drupal-emacs

Ich bin ein Vollzeit-Drupal Entwickler.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top