     (plw-refresh-file-buffer (buffer-file-name))
     (semantic-force-refresh)))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; indentation 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; js mode
+(require 'js)
+
+;; taken from js--proper-indentation from js-mode
+(defun pjs--proper-indentation (parse-status)
+  "Return the proper indentation for the current line."
+  (save-excursion
+    (back-to-indentation)
+    (cond ((nth 4 parse-status)    ; inside comment
+           (js--get-c-offset 'c (nth 8 parse-status)))
+          ((nth 3 parse-status) 0) ; inside string
+;;          ((eq (char-after) ?#) 0) ;; # is a normal char in pjs
+          ((save-excursion (js--beginning-of-macro)) 4)
+          ;; Indent array comprehension continuation lines specially.
+          ((let ((bracket (nth 1 parse-status))
+                 beg)
+             (and bracket
+                  (not (js--same-line bracket))
+                  (setq beg (js--indent-in-array-comp bracket))
+                  ;; At or after the first loop?
+                  (>= (point) beg)
+                  (js--array-comp-indentation bracket beg))))
+          ((js--ctrl-statement-indentation))
+          ((js--multi-line-declaration-indentation))
+          ((nth 1 parse-status)
+	   ;; A single closing paren/bracket should be indented at the
+	   ;; same level as the opening statement. Same goes for
+	   ;; "case" and "default".
+           (let ((same-indent-p (looking-at "[]})]"))
+                 (switch-keyword-p (looking-at "default\\_>\\|case\\_>[^:]"))
+                 (continued-expr-p (js--continued-expression-p)))
+             (goto-char (nth 1 parse-status)) ; go to the opening char
+             (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
+                 (progn ; nothing following the opening paren/bracket
+                   (skip-syntax-backward " ")
+                   (when (eq (char-before) ?\)) (backward-list))
+                   (back-to-indentation)
+                   (let* ((in-switch-p (unless same-indent-p
+                                         (looking-at "\\_<switch\\_>")))
+                          (same-indent-p (or same-indent-p
+                                             (and switch-keyword-p
+                                                  in-switch-p)))
+                          (indent
+                           (cond (same-indent-p
+                                  (current-column))
+                                 (continued-expr-p
+                                  (+ (current-column) (* 2 js-indent-level)
+                                     js-expr-indent-offset))
+                                 (t
+                                  (+ (current-column) js-indent-level
+                                     (pcase (char-after (nth 1 parse-status))
+                                       (?\( js-paren-indent-offset)
+                                       (?\[ js-square-indent-offset)
+                                       (?\{ js-curly-indent-offset)))))))
+                     (if in-switch-p
+                         (+ indent js-switch-indent-offset)
+                       indent)))
+               ;; If there is something following the opening
+               ;; paren/bracket, everything else should be indented at
+               ;; the same level.
+               (unless same-indent-p
+                 (forward-char)
+                 (skip-chars-forward " \t"))
+               (current-column))))
+
+          ((js--continued-expression-p)
+           (+ js-indent-level js-expr-indent-offset))
+          (t 0))))
+
+;; taken from js-indent-line from js-mode
+(defun pjs-indent-line ()
+  "Indent the current line as JavaScript."
+  (interactive)
+  (let* ((parse-status
+          (save-excursion (syntax-ppss (point-at-bol))))
+         (offset (- (point) (save-excursion (back-to-indentation) (point)))))
+    (indent-line-to (pjs--proper-indentation parse-status))
+    (when (> offset 0) (forward-char offset))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; new mode definition
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;  (c-common-init 'c-mode)

  ;; indentation like js mode
  (setq-local indent-line-function 'js-indent-line)
  (setq-local beginning-of-defun-function 'js-beginning-of-defun)
  (setq-local end-of-defun-function 'js-end-of-defun)
  (setq-local open-paren-in-column-0-is-defun-start nil)

;; autocomplete
(require 'ac-pjs)

;; pjs files are pjs modes
(setq auto-mode-alist (cons '("\\.pjs" . pjs-mode) auto-mode-alist))
