unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* indentation issues when editing a PHP file
@ 2004-03-26 17:34 Saifi Khan
  2004-03-26 20:03 ` Marcelo Toledo
  2004-03-27  6:29 ` Emory Smith
  0 siblings, 2 replies; 3+ messages in thread
From: Saifi Khan @ 2004-03-26 17:34 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]

Hi:
                                                                               

When editing a PHP file, the '{' curly brace
positions itself as indicated below.
                                                                               

class Log
{
    function log( $msg )
    ...{
    ...}
}

the dots (.) are for indicating the spaces.
                                                                               

The following indentation style is what I would like to see.
                                                                               

class Log
{
    function log( $msg )
    {
    }
}
                                                                               

I have spent sometime looking at the .emacs file, indentation options
and other mails on the mailing list.
                                                                               

I have been able to setup CCmode for C, C++ and Java,
however this just beats me.

What options should I place in my php-hook-function ?
I will appreciate suggestions to solve this problem.
                                                                               

thanks
Saifi.

Ps. please see the attached .emacs file

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

[-- Attachment #2: emacs-to-list --]
[-- Type: application/octet-stream, Size: 7760 bytes --]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; .emacs file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GLOBAL BEGIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
(setq-default teach-extended-commands-p t)

;; editable screen 72 character wide
(setq-default fill-column 72)

; display line and column number in mode line
(setq-default line-number-mode t)
(setq-default column-number-mode t)

; all indentation should be made from spaces only
(setq-default indent-tabs-mode nil)

; tab stops list
(setq-default tab-stop-list 
   '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))

; tab width should be 4
(setq-default tab-width 4)

;; always end a file with a newline
(setq require-final-newline t)

;; stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)

; automatically insert newline
;(setq-default c-auto-newline t)

;(setq-default c-basic-offset 4)

;; cc-mode style variables are local
(setq-default c-style-variables-are-local-p t)

;; turn on font-lock mode
;;(global-font-lock-mode t)
;;(global-font-lock-mode nil)

;; enable visual feedback on selections
;;(setq-default transient-mark-mode t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GLOBAL END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; backup
(setq make-backup-files t)
(setq backup-by-copying-when-linked t)


;; automatic display of matching parens
(setq blink-matching-paren t)

;;
;; display date and time information
;;
(set-variable (quote display-time-day-and-date) t)
(set-variable (quote display-time-interval) 30)
(set-variable (quote display-time-24hr-format) t)
(display-time )


;;;;;;;;;;;;;;;;;;;;;;;;;; PROGRAMMING STYLES ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  HTML, XML style
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook 'html-mode-hook
          (lambda()
            (setq indent-line-function 'indent-relative)
            ))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; java style mode 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst reco-java-mode-style
  '(
    (c-backslash-column             . 72)

    (c-echo-syntactic-information-p . t)

    (c-toggle-auto-hungry-state 1)

    (c-electric-pound-behavior      . (align-left))

    (c-offsets-alist . (
                        (inher-cont            . c-lineup-java-inher)
                        (inline-open           . 0)
                        (inline-close          . c-lineup-close-paren) 
                        (func-decl-cont        . c-lineup-java-throws)
                        (arglist-cont-nonempty . c-lineup-arglist)
                        (arglist-close         . c-lineup-close-paren)
                        (substatement-open     . 0)
                        (inexpr-class          . c-lineup-inexpr-block)
                        (inexpr-statement      . c-lineup-inexpr-block)
                        ))
    )
  "java style"
  )


; define the hook
(defun reco-java-mode-hook()
  (c-add-style "java style" reco-java-mode-style t))


; add the hook
(add-hook 'java-mode-hook  'reco-java-mode-hook)


; compile support
(require 'compile)
(add-hook 'java-mode-hook
          (lambda()
            (set (make-local-variable 'compile-command)
                 (let ((file (file-name-nondirectory buffer-file-name)))
                   (concat "javac -d . " file)
                   ))))


;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C, C++ coding style 
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;
;; indentation structure
;;
;; 1: opening and closing braces '{' and '}'
;; 2: opening and closing parens of a function should be 
;;    in the same column
;; 2: auto single space between '(' and next char, last char and ')'
;; 3: auto single space after typed comma ','
;;


;; reco-c-cpp-mode-common-style

(defconst reco-c-cpp-mode-common-style
  '(
    (c-basic-offset         . 4)

    (tab-width              . 4)

    (c-tab-always-indent    . t)

    (indent-tabs-mode       . nil)

    (c-echo-syntactic-information-p . t)

    (c-toggle-auto-hungry-state 1)

    (c-comment-prefix-regexp *)

    (c-hanging-braces-alist . ((substatement-open (after))
			       (brace-list-open)
			       ))

    (c-hanging-colons-alist . ((member-init-intro (before))
			       (inher-intro)
			       (case-label (after))
			       (label (after))
			       (access-label (after))
			       ))

    (c-cleanup-list         . ((scope-operator)
			       (empty-defun-braces)
			       (defun-close-semi)
			       (list-close-comma)
			       ))

    (c-offsets-alist        . (
                               (c                 . c-lineup-C-comments)
                               (func-decl-cont    . c-lineup-java-throws)
                               ;(member-init-intro)
                               (member-init-cont  . c-lineup-multi-inher)
                               ;(inher-intro)
                               (inher-cont        . c-lineup-multi-inher)
                               (case-label        . 0)
                               ;(access-label      . 0)
                               ;(label             . ----)
                               (do-while-closure  . 0)
                               ;(brace-list-open)
                               ;(brace-list-close . c-lineup-arglist-close-under-paren )
                               ;(brace-list-intro . c-lineup-arglist-intro-after-paren)
                               ;(brace-list-entry)
                               ;(brace-entry-open)
                               ;(arglist-intro . c-lineup-arglist-intro-after-paren)
                               (arglist-intro  . +)
                               ;(arglist-cont)
                               (arglist-cont-nonempty . c-lineup-arglist)
                               (arglist-close     . c-lineup-close-paren)
                               (stream-op         . c-lineup-streamop)
                               ;(inclass)
                               ;(friend)
                               ;(namespace-open)
                               (namespace-close   . 0)
                               ;(extern-lang-open)
                               (extern-lang-close . 0)
                               (statement-cont    . c-lineup-math)
			       (substatement-open . 0) 
			       ))

    )
  "C/C++ programming style"
)


;; reco-c-cpp-mode-common-hook
(defun reco-c-cpp-mode-common-hook()
  (c-add-style "reco c cpp style" reco-c-cpp-mode-common-style t)
  (setq tab-width 4)
)

;; add the hook
(add-hook  'c-mode-common-hook  'reco-c-cpp-mode-common-hook)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PHP mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun reco-php-mode-hook ()
  (setq tab-width 4)
    (define-key c-mode-base-map [RET] 'newline-and-indent)
    (c-offsets-alist . (
                        (statement-cont . c-lineup-math)
                        ))
    )

(add-hook   'php-mode-hook  'reco-php-mode-hook)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;
;; run clisp from within emacs
;;
(setq inferior-lisp-program "/usr/local/bin/clisp")

;;
;; browser program (links)
;;
(setq browse-url-browser-function  'browse-url-w3)
;;(setq browse-url-generic-program "/usr/bin/links")
;;(setq browse-url-generic-program "/usr/bin/w3m")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Function Key Mappings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


[-- Attachment #3: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-27  6:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-26 17:34 indentation issues when editing a PHP file Saifi Khan
2004-03-26 20:03 ` Marcelo Toledo
2004-03-27  6:29 ` Emory Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).