[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tab / indent / spaces / modes [PHP coding]
From: |
Jari Aalto+mail.tpu |
Subject: |
Re: tab / indent / spaces / modes [PHP coding] |
Date: |
Sun, 08 Feb 2004 12:27:28 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (windows-nt) (i386-msvc-nt5.0.2195) |
* Fri 2004-01-30 Emory Smith <emory.smith <AT> mac.com> gnu.emacs.help
*
<http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
| On Jan 27, 2004, at 2:07 PM, kgold wrote:
|
| > richard <AT> sunsetandlabrea.com (Richard Chamberlain) writes:
| >>
| >> I'm using php-mode and I want to be able to switch off the indentation
| >> mode, because what I want for formatting and what php-mode suggests is
| >> different.
| >
| > Rather than turn off indentation, why not just customize it to format
| > the way you like? In emacs, nearly everything is customizable.
| >
|
| im also using php and having trouble with indentation. i would like
| to keep the indentation on and customize it (as kgold suggested).
|
| my main problem is with comments (// or /**/). php-mode seems to not
| recognize them as comments and gives me doubly indented line after i
| use one (even if they are after the semicolon.
|
| so i was wondering how i might find out (and change) what character
| sequences php-mode recognizes as comment delimiters and what it does
| when it recognizes one.
I use this something likes this for PHP (This is only part of the
setup). Hope it gives some ideas. PHP uses cc-mode, so the indentation
must be defined there.
Jari
(require 'cl)
(setq tab-stop-list
(let ((i 4) list)
(while (< i 80)
(setq list (cons i list))
(setq i (+ i 4)))
(reverse list)))
(defun my-tmp-set-tab-key-to-run-4-spaces (map)
"Define TAB key to run 4 spaces."
(setq indent-tabs-mode nil) ;; do NOT use tab characters
(define-key map "\t" 'tab-to-tab-stop))
(defun my-tmp-c-coding-setup ()
"Define C and C++ defaul coding style."
;; See cc-compat.el
(setq c-basic-offset 4) ;; Default was 2
(setq c-indent-level 4) ;; Default was 2
(setq c-label-offset 0) ;; Default was -2
(setq c-continued-statement-offset 0) ;; Default was 2
;; See cc-vars.el / C-h v c-offsets-alist
(c-set-offset 'comment-intro '(c-lineup-comment))
(c-set-offset 'topmost-intro-cont '+) ;; Was c-lineup-topmost-intro-cont
(c-set-offset 'arglist-intro '+) ;; Default was +
(c-set-offset 'arglist-close 0) ;; Default was +
;; (c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist))
(c-set-offset 'access-label 0) ;; Default was -
(c-set-offset 'label 0) ;; Default was 2
(c-set-offset 'defun-block-intro '+)
(c-set-offset 'statement-cont 0) ;; Default was +
(c-set-offset 'substatement-open 0)
(c-set-offset 'statement-block-intro '+))
(defun my-tmp-c-mode-setup ()
"Prepare C and C++ mode."
(dolist (hook '(c++-mode-hook
c-mode-hook))
(add-hook hook 'my-tmp-c-coding-setup)))
(my-tmp-c-mode-setup)
;; Status: 3rd party package http://sourceforge.net/projects/php-mode/
;;
;; Emacs does not have built-in PHP coding support
;; This mode uses C mode
(defun my-tmp-php-compile-command ()
"Set default compile command."
(when (and (string-match "php" (symbol-name major-mode))
(executable-find "php"))
(setq compile-command "php ")))
(defun my-tmp-php-mode-turn-on-settings ()
"When ´php-mode' is turned on, run these settings."
(setq c-auto-newline t) ;; See M-x c-toggle-auto-state
;; Cancel CC mode's electric keys
(define-key php-mode-map "/" 'self-insert-command)
(define-key php-mode-map "," 'self-insert-command)
(define-key php-mode-map ";" 'self-insert-command)
(define-key php-mode-map "(" 'self-insert-command)
(define-key php-mode-map ")" 'self-insert-command))
(defun my-tmp-php-mode ()
"Write PHP code."
(interactive)
(cond
((fboundp 'php-mode)
(let ((func 'php-mode))
(funcall func)))
((fboundp 'html-helper-mode)
(let ((func 'html-helper-mode))
(funcall func 1))
(my-tmp-set-tab-key-to-run-4-spaces (current-local-map)))
((fboundp 'html-mode)
(html-mode)
(my-tmp-set-tab-key-to-run-4-spaces (current-local-map)))
(t
(text-mode)))
(my-tmp-php-compile-command))
(defun my-tmp-php-mode-setup ()
"Install PHP support."
(pushnew '("\\.php[s34]?$" . my-tmp-php-mode) auto-mode-alist :test 'equal)
(cond
((or (fboundp 'php-mode)
(locate-library "php-mode"))
(autoload 'php-mode "php-mode" "" t)
(setq php-manual-url "http://www.php.net/manual/en/")
(add-hook 'php-mode-user-hook 'my-tmp-php-mode-turn-on-settings))))
(my-tmp-php-mode-setup)
--
http://tiny-tools.sourceforge.net/
Swatch @time http://www.mir.com.my/iTime/itime.htm
http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses! http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences http://www.opensource.org/licenses/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: tab / indent / spaces / modes [PHP coding],
Jari Aalto+mail.tpu <=