Commits

Anonymous committed d20f5c2 Merge

Fix javascript function prototype indentation, from Sebastian Delmont <sdelmont@zonageek.com>.

  • Participants
  • Parent commits 00953ba, 66cf6e0

Comments (0)

Files changed (2)

+2002-05-21  Ville Skyttä  <ville.skytta@xemacs.org>
+
+	* javascript-mode.el (javascript-mode): Fix prototype function
+	indentation, from Sebastian Delmont <sdelmont@zonageek.com>.
+
+	Sebastian's comments:
+
+	It looks like cc-mode doesn't like JavaScript's prototype
+	function declarations.	This triggers indentation errors in a few
+	cases, since the indentation engine considers the function block
+	as a brace-list	entry, and it won't detect language constructs
+	(i.e. "if", "switch", etc) inside it.  Here's a gnu.emacs.bug
+	thread that discusses the problem, and proposes a solution:
+	http://groups.google.com/groups?hl=en&lr=&th=bae37c6e427b29db&rnum=3
+
 2002-05-14  Steve Youngs  <youngs@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.56 released.

File javascript-mode.el

 ;; a lot afterwards by Ville Skyttä.
 
 ;; Contributors:
-;;   Sreng Truong (bug fix for 21.1)
+;;   Sreng Truong      (bug fix for 21.1)
+;;   Sebastian Delmont (fix for prototype function indentation problems)
 
 ;; TODO:
 ;; - Multiple font-lock/highlight levels.
 
 ;; ------------------------------------------------------------------------ ;;
 
-(defconst javascript-mode-version "1.4" "Version of `javascript-mode'.")
+(defconst javascript-mode-version "1.5" "Version of `javascript-mode'.")
 
 ;; ------------------------------------------------------------------------ ;;
 
     (setq local-abbrev-table javascript-mode-abbrev-table)
     (c-set-offset 'inher-cont '+)
 
+    ; cc-mode does not handle JavaScript prototype function declarations well.
+    ; Thanks to Sebastian Delmont.
+    (set (make-local-variable 'c-lambda-key) "function")
+    (c-set-offset 'inlambda 0)
+
     ; Restore the original c++-mode-hook.
     (setq c++-mode-hook current-c++-mode-hook)