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

  ;; (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
  (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
  ;; n 列以上はハイライトで警告
  ;; (setq whitespace-line-column 90)


  (setq whitespace-action '(auto-cleanup))
  (defun kui/whitespace-auto-cleanup-enable ()
    (interactive)
    (setq-local whitespace-action '(auto-cleanup)))
  (defun kui/whitespace-auto-cleanup-disable ()
    (interactive)
    (setq-local whitespace-action nil))
  )

;; ctag-update.el 自動で TAGS アップデートしてくれる
(use-package ctags-update
  :config
  (set 'ctags-update-command
       (kui/find-if-executable '("ctags-exuberant"
                                 "exuberant-ctags"
                                 "ctags")))
  )

;; 一度に複数のカーソルを操作
(use-package multiple-cursors
  :bind (("M-m n" . mc/mark-next-like-this)
         ("M-m p" . mc/mark-previous-like-this)
         ("M-m a" . mc/mark-all-like-this)
         ("M-m i" . mc/mark-more-like-this-extended))
  :init
  (multiple-cursors-mode)
  )

;; -------------------------------------------------------------------------
;; メジャーモードの設定や読み込み

;; メジャーモードのインストールはオプショナル
(setq use-package-always-ensure nil)

(use-package emacs-lisp-mode
  :no-require t
  :bind (:map emacs-lisp-mode-map
              ("C-c f f" . find-function)
              ("C-c f v" . find-variable)
              ("C-c f l" . find-library)
              ("C-c d f" . describe-function)
              ("C-c d v" . describe-variable))
  )

;; http://emacs-jp.github.io/programming/golang.html
(use-package go-mode
  :no-require t
  :bind (:map go-mode-map
              ("M-." . godef-jump)
              ("M-," . pop-tag-mark))
  :config
  (use-package go-autocomplete :ensure t)
  (use-package helm
    :config
    (defvar kui/helm-go-source
      '((name . "Helm Go")
        (candidates . (lambda ()
