   ;; (ac-show-menu-immediately-on-auto-complete t)
   )
 
-(kui/after-loaded "flymake"
-  (kui/with-pkg 'popup
-
-    ;; flymake 現在行のエラーをpopup.elのツールチップで表示する
-    ;; https://gist.github.com/292827
-    (defvar flymake-display-err-delay 1
-      "delay to display flymake error message ")
-    (defvar flymake-display-err-timer nil
-      "timer for flymake-display-err-menu-for-current-line")
-    (defvar flymake-display-err-before-line nil)
-    (defvar flymake-display-err-before-colmun nil)
-    (defun flymake-display-err-menu-for-current-line ()
-      (interactive)
-      (let* ((line-no (line-number-at-pos))
-             (line-err-info-list
-              (nth 0 (flymake-find-err-info flymake-err-info line-no))))
-        (when (and (flymake-display-err-check-moved line-no (current-column))
-                   line-err-info-list)
-          (setq flymake-display-err-before-line-no line-no)
-          (let* ((count (length line-err-info-list))
-                 (menu-item-text nil))
-            (while (> count 0)
-              (setq menu-item-text
-                    (flymake-ler-text (nth (1- count) line-err-info-list)))
-              (let* ((file (flymake-ler-file (nth (1- count)
-                                                  line-err-info-list)))
-                     (line (flymake-ler-line (nth (1- count)
-                                                  line-err-info-list))))
-                (if file
-                    (setq menu-item-text
-                          (concat menu-item-text " - " file "("
-                                  (format "%d" line) ")"))))
-              (setq count (1- count))
-              (if (> count 0) (setq menu-item-text (concat menu-item-text "\n")))
-              )
-            (popup-tip menu-item-text)))))
-
-    (defun flymake-display-err-check-moved (cur-line cur-col)
-      (let* ((is-not-moved (and flymake-display-err-before-line
-                                flymake-display-err-before-colmun
-                                (= cur-line flymake-display-err-before-line)
-                                (= cur-col flymake-display-err-before-colmun))))
-        (setq flymake-display-err-before-line cur-line
-              flymake-display-err-before-colmun cur-col)
-        (not is-not-moved)))
-
-    (unless flymake-display-err-timer
-      (setq flymake-display-err-timer
-            (run-with-idle-timer flymake-display-err-delay t
-                                 'flymake-display-err-menu-for-current-line)))
-
-    ;; (global-set-key "\M-e"
-    ;;                 '(lambda ()
-    ;;                    (interactive)
-    ;;                    (message "next error")
-    ;;                    (flymake-goto-next-error)
-    ;;                    (flymake-display-err-menu-for-current-line)))
-    ;; (global-set-key "\M-E"
-    ;;                 '(lambda ()
-    ;;                    (interactive)
-    ;;                    (message "prev error")
-    ;;                    (flymake-goto-prev-error)
-    ;;                    (flymake-display-err-menu-for-current-line)))
-    ))
-
-(kui/with-pkg 'helm
+(use-package helm
+  :bind (("C-x C-f" . helm-find-files)
+         ("C-x a" . helm-apropos)
+         ("C-x b" . helm-buffers-list)
+         ("M-i" . helm-buffers-list)
+         ("M-o" . helm-imenu)
+         ("C-o" . helm-imenu)
+         ("C-s" . helm-occur)
+         ("M-x" . helm-M-x))
+  :bind (:map helm-map
+              ("C-h" . delete-backward-char)
+              ("C-w" . kui/backward-kill-word-or-kill-region)
+              ("C-u" . kui/backward-kill-line)
+              ("TAB" . helm-execute-persistent-action))
+  :config
   (setq
-   helm-ff-transformer-show-only-basename nil
-   helm-buffer-max-length 20)
-
-  (global-set-key "\C-xa" 'helm-apropos)
-  (global-set-key "\C-x\C-f" 'helm-find-files)
-  (global-set-key "\C-xb" 'helm-buffers-list)
-  (global-set-key "\M-o" 'helm-imenu)
-  (global-set-key "\C-o" 'helm-imenu)
-  (global-set-key "\M-i" 'helm-buffers-list)
-  (global-set-key "\C-s" 'helm-occur)
-  (global-set-key "\M-x" 'helm-M-x)
-
-  (kui/after-loaded 'helm
-    (define-key helm-map "\C-h" 'delete-backward-char)
-    (define-key helm-map "\C-w" 'kui/backward-kill-word-or-kill-region)
-    (define-key helm-map "\C-u" 'kui/backward-kill-line)
-    (define-key helm-map "TAB" 'helm-execute-persistent-action))
-  (kui/after-loaded 'helm-find-files
-    (define-key helm-find-files-map "\M-l" 'helm-execute-persistent-action))
-
-  (kui/with-pkg 'helm-swoop
-    (define-key helm-swoop-map "\C-w" 'kui/backward-kill-word-or-kill-region)
-    (global-set-key "\C-s" 'helm-swoop))
-  )
-
-;; whitespace-mode
-(kui/with-pkg 'whitespace
+   ;; helm-buffer-max-length 20
+   )
+
+  (use-package helm-swoop
+    :bind ("C-s" . helm-swoop)
+    :bind (:map helm-swoop-map
+                ("C-w" . kui/backward-kill-word-or-kill-region)))
+  )
+
+(use-package whitespace
+  :config
   ;; n 列以上はハイライトで警告
   ;; (setq whitespace-line-column 90)
 

                    'kui/coffee-indent-line)))
  )

;; css-mode
(setq css-indent-offset 2)
(kui/add-to-list-if-exist 'ac-modes 'css-mode)

;; scss-mode
(kui/with-lib "scss-mode"
  (setq scss-compile-at-save nil))

;; javascript
(defun kui/find-node-modules-bin (binname)
  "Find executable file named BINNAME from the node_modules directory"
  (let* ((moddir (kui/traverse-parents-for "node_modules"))
         (bin (if moddir (format "%s/.bin/%s" moddir binname))))
    (if (file-executable-p bin) bin)))
(kui/with-lib "flycheck"
  (defun kui/flycheck-set-node-modules-bin (checker binname)
    (let* ((bin (kui/find-node-modules-bin binname)))
      (when bin
        (message "auto-detect %s: %s" binname bin)
        (flycheck-set-checker-executable checker bin))))
  (defun kui/flycheck-init-js ()
    ;; use jshint/eslint in node_modules/.bin
    (kui/flycheck-set-node-modules-bin 'javascript-jshint "jshint")
    (kui/flycheck-set-node-modules-bin 'javascript-eslint "eslint")
    ;; disable jshint if eslint can be used
    ;;   commented out because current version flycheck dose NOT work right
    ;; (when (flycheck-may-use-checker 'javascript-eslint)
    ;;   (message "disale jshint on flycheck")
    ;;   (flycheck-disable-checker 'javascript-jshint))
    )
  (add-hook 'js-mode-hook 'kui/flycheck-init-js)
  (add-hook 'js2-mode-hook 'kui/flycheck-init-js))
(kui/after-loaded "js"
  (setq js-indent-level 2))
(kui/with-pkg 'js2-mode
  (js2-mode-hide-warnings-and-errors)
  (add-to-list 'auto-mode-alist '("\\.js\\'"  . js2-mode)))

;; html-mode
(kui/add-to-list-if-exist 'ac-modes 'html-mode)

;; multi-web-mode
(kui/with-lib "multi-web-mode"
  (add-to-list 'auto-mode-alist '("\\.html\\'" . multi-web-mode)))
(kui/after-loaded "multi-web-mode"
  (setq mweb-default-major-mode 'html-mode)
  (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
                    (js-mode "<script>" "</script>")


(message "End init.el %s" (current-time-string))
(message "Elapsed time: %s sec" (- (float-time) kui/init-start-time))
;;; init.el ends here
