From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jari.aalto@tamk.fi (Jari Aalto+mail.tpu) Newsgroups: gmane.emacs.help Subject: Re: tab / indent / spaces / modes [PHP coding] Date: Sun, 08 Feb 2004 12:27:28 +0200 Organization: Private Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1076236364 2332 80.91.224.253 (8 Feb 2004 10:32:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 Feb 2004 10:32:44 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 08 11:32:40 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApmEx-0008Fn-00 for ; Sun, 08 Feb 2004 11:32:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ApmD1-0000iW-Bw for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Feb 2004 05:30:39 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fi.sn.net!newsfeed2.fi.sn.net!newsfeed.kolumbus.fi!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 134 Original-NNTP-Posting-Host: a110t7.elisa.omakaista.fi Original-X-Trace: phys-news1.kolumbus.fi 1076235382 11766 81.197.3.110 (8 Feb 2004 10:16:22 GMT) Original-X-Complaints-To: abuse@kolumbus.fi Original-NNTP-Posting-Date: Sun, 8 Feb 2004 10:16:22 +0000 (UTC) User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (windows-nt) (i386-msvc-nt5.0.2195) Cancel-Lock: sha1:QAU3RueNUSIMuy1By6MznN2ZV6E= Original-Xref: shelby.stanford.edu gnu.emacs.help:120760 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:16708 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16708 * Fri 2004-01-30 Emory Smith mac.com> gnu.emacs.help * | On Jan 27, 2004, at 2:07 PM, kgold wrote: | | > richard 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/