 ;;; php-mode.el --- major mode for editing PHP code
 
-;; Copyright (C) 1999-2004 Turadg Aleahmad
-
-;; Maintainer: Turadg Aleahmad <turadg at users.sourceforge.net>
+;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad
+;;               2008 Aaron S. Hawley
+
+;; Maintainer: Aaron S. Hawley <ashawley at users.sourceforge.net>
+;; Author: Turadg Aleahmad, 1999-2004
 ;; Keywords: php languages oop
 ;; Created: 1999-05-17
-;; Modified: 2004-01-24
+;; Modified: 2007-01-02
 ;; X-URL:   http://php-mode.sourceforge.net/
 
-(defconst php-version "1.1.0"
+(defconst php-mode-version-number "1.4.0"
   "PHP Mode version number.")
 
 ;;; License
 
-;; This program is free software; you can redistribute it and/or
+;; This file is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
+;; as published by the Free Software Foundation; either version 3
 ;; of the License, or (at your option) any later version.
 
-;; This program is distributed in the hope that it will be useful,
+;; This file is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+;; along with this file; if not, write to the Free Software
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
 
 ;;; Usage
 
-;; Rename this file to php-mode.el if it isn't already then place it in
-;; your Emacs lisp path (eg. site-lisp) and add to your .emacs file:
+;; Put this file in your Emacs lisp path (eg. site-lisp) and add to
+;; your .emacs file:
+;;
 ;;   (require 'php-mode)
 
-;; If you want colorization, turn on global-font-lock or
-;; add this to your .emacs:
-;;   (add-hook 'php-mode-user-hook 'turn-on-font-lock)
-
 ;; To use abbrev-mode, add lines like this:
-;;   (add-hook 'php-mode-user-hook
+;;   (add-hook 'php-mode-hook
 ;;     '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends")))
 
 ;; To make php-mode compatible with html-mode, see http://php-mode.sf.net

  ;; problem, please let me know.  Of course, you're welcome to
  ;; uncomment this line in your installation.
;  (modify-syntax-entry ?$ "." php-mode-syntax-table)
  
  ;; The above causes XEmacs to handle shell-style comments correctly,
  ;; but fails to work in GNU Emacs which fails to interpret \n as the
  ;; end of the comment.
  (if xemacsp (progn
		(modify-syntax-entry ?# "< b" php-mode-syntax-table)
		(modify-syntax-entry ?\n "> b" php-mode-syntax-table)
		))
  
  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults
 	'((php-font-lock-keywords-1
 	   php-font-lock-keywords-2
 	   ;; Comment-out the next line if the font-coloring is too
 	   ;; extreme/ugly for you.
 	   php-font-lock-keywords-3
 	   )
 	  nil				; KEYWORDS-ONLY
 	  T				; CASE-FOLD
 	  nil				; SYNTAX-ALIST
 	  nil				; SYNTAX-BEGIN
 	  (font-lock-syntactic-keywords . php-font-lock-syntactic-keywords)))
  
  (setq font-lock-maximum-decoration t
	case-fold-search t		; PHP vars are case-sensitive
	imenu-generic-expression php-imenu-generic-expression)
  
  ;; Do not force newline at end of file.  Such newlines can cause
  ;; trouble if the PHP file is included in another file before calls
  ;; to header() or cookie().
  (set (make-local-variable 'require-final-newline) nil)
  (set (make-local-variable 'next-line-add-newlines) nil)
  
  ;; PEAR coding standards
  (make-local-hook 'php-mode-pear-hook)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (set (make-local-variable 'tab-width) 4)) nil t)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (set (make-local-variable 'c-basic-offset) 4)) nil t)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (set (make-local-variable 'c-hanging-comment-ender-p) nil)) nil t)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (set (make-local-variable 'indent-tabs-mode) nil)) nil t)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (c-set-offset 'block-open' - )) nil t)
  (add-hook 'php-mode-pear-hook
	    (lambda nil (c-set-offset 'block-close' 0 )) nil t)

  (if (or php-mode-force-pear
	  (and (stringp buffer-file-name)
	       (string-match "PEAR\\|pear"
			     (buffer-file-name))
	       (string-match "\\.php$" (buffer-file-name))))
      (run-hooks 'php-mode-pear-hook))
  
  (run-hooks 'php-mode-user-hook)
  )

;; Make php-mode the default mode for PHP source code buffers.
;;;###autoload
(let ((php-file-patterns-temp php-file-patterns))
  (while php-file-patterns-temp
    (add-to-list 'auto-mode-alist
		  (cons (car php-file-patterns-temp) 'php-mode))
    (setq php-file-patterns-temp (cdr php-file-patterns-temp))))

;; Handle Speedbar
(if php-mode-speedbar-open
    (speedbar 1))
(if (and php-speedbar-config (symbolp 'speedbar))
    (speedbar-add-supported-extension "\\.\\(inc\\|php[s34]?\\)"))

;; Make a menu keymap (with a prompt string)
;; and make it the menu bar item's definition.

;; Rosenfeld, Fred Yankowski, Craig Andrews, John Keller, Ryan
;; Sammartino, ppercot, Valentin Funk, Stig Bakken, Gregory Stark,
;; Chris Morris, Nils Rennebarth, Gerrit Riessen, Eric Mc Sween,
;; Ville Skytta, Giacomo Tesio, Lennart Borgman, Stefan Monnier,
;; Aaron S. Hawley, Ian Eure, Bill Lovett

;;; Changelog:

;; 1.4
;;   Updated GNU GPL to version 3.  Ported to Emacs 22 (CC mode
;;   5.31). M-x php-mode-version shows version.  Provide end-of-defun
;;   beginning-of-defun functionality. Support add-log library.
;;   Fix __CLASS__ constant (Ian Eure).  Allow imenu to see visibility
;;   declarations -- "private", "public", "protected". (Bill Lovett)
;;
;; 1.3
;;   Changed the definition of # using a tip from Stefan
;;   Monnier to correct highlighting and indentation. (Lennart Borgman)
;;   Changed the highlighting of the HTML part. (Lennart Borgman)
;;
;; 1.2
;;   Implemented php-show-arglist, C-. (Engelke Eschner)
;;   Implemented php-complete-function, M-tab (Engelke Eschner)
;;   Re-enabled # comment detection in GNU Emacs (Urban Mller)
;;   Fixed some keybindings and default settings (Engelke Eschner)
;;
;; 1.1
;;   Added PHP5 support (Giacomo Tesio)
;;     known problem: doesn't highlight after first 'implements'
