   (sml/setup))
 
 (use-package google-translate
-  :defer t
-  :init (require 'google-translate-default-ui))
+  :commands (google-translate-query-translate)
+  :defer t)
 
 (use-package mwim
   :bind ("C-a" . mwim-beginning-of-code-or-line))

         ("C-c h" . helm-command-prefix)
         ("C-c <SPC>" . helm-all-mark-rings)))

(use-package ag)
(use-package helm-ag
  ;; :init
  ;; (setq helm-ag-fuzzy-match t)
  :config
  (setq helm-ag-base-command "ag --smart-case --nocolor --nogroup")
  (setq helm-ag-insert-at-point 'symbol)
  (add-hook 'helm-ag-mode-hook (lambda () (grep-mode))))

(use-package helm-descbinds
  :config (helm-descbinds-mode))

(use-package helm-swoop
  :config
  (define-key helm-swoop-map (kbd "C-r") 'helm-previous-line)
  (define-key helm-swoop-map (kbd "C-s") 'helm-next-line)


(defun my-c-mode-common-hook ()
  (progn
    (use-package rtags
      ;; https://github.com/Andersbakken/rtags + https://github.com/rizsotto/Bear
      ;; to create compile_commands.json: bear scons
      :init
      (add-hook 'c-mode-common-hook
                (lambda ()
                  (define-key c-mode-base-map (kbd "M-.") 'rtags-find-symbol-at-point)
                  (define-key c-mode-base-map (kbd "M-,") 'rtags-location-stack-back))))
    (use-package clang-format
      :init
      (setq clang-format-executable
            (if (executable-find "clang-format") "clang-format"
              (if (executable-find "clang-format-3.8") "clang-format-3.8"
                (if (executable-find "clang-format-3.7") "clang-format-3.7"
                  (if (executable-find "clang-format-3.6") "clang-format-3.6"
                    (if (executable-find "clang-format-3.5") "clang-format-3.5"))))))
      (setq clang-format-style (concat "{BasedOnStyle: Google,"
                                       " BinPackParameters: true,"
                                       " IndentWidth: 2,"
                                       " ColumnLimit: 90,"
                                       " AlwaysBreakBeforeMultilineStrings: false,"
                                       " SpacesBeforeTrailingComments: 4,"
                                       " AllowShortFunctionsOnASingleLine: false,"
                                       " NamespaceIndentation: All,"
                                       " BreakBeforeBraces: Linux,"
                                       " UseTab: Never,"
                                       " ConstructorInitializerIndentWidth: 2,"
                                       " ContinuationIndentWidth: 2,"
                                       " Standard: C++11}"))
      :config
      ;; without -sort-includes option:
      (defun clang-format-region (char-start char-end &optional style)
        "Use clang-format to format the code between START and END according to STYLE.
     If called interactively uses the region or the current statement if there
     is no active region.  If no style is given uses `clang-format-style'."
        (interactive
         (if (use-region-p)
             (list (region-beginning) (region-end))
           (list (point) (point))))

        (unless style
          (setq style clang-format-style))

        (let ((start (1- (position-bytes char-start)))
              (end (1- (position-bytes char-end)))
              (cursor (1- (position-bytes (point))))
              (temp-buffer (generate-new-buffer " *clang-format-temp*"))
              (temp-file (make-temp-file "clang-format")))
          (unwind-protect
              (let (status stderr operations)
                (setq status
                      (call-process-region
                       (point-min) (point-max) clang-format-executable
                       nil `(,temp-buffer ,temp-file) nil
                       "-output-replacements-xml"
                       "-assume-filename" (or (buffer-file-name) "")
                       "-style" style
                       "-offset" (number-to-string start)
                       "-length" (number-to-string (- end start))
                       "-cursor" (number-to-string cursor)))
                (setq stderr
                      (with-temp-buffer
                        (insert-file-contents temp-file)
                        (when (> (point-max) (point-min))
                          (insert ": "))
                        (buffer-substring-no-properties
                         (point-min) (line-end-position))))

                (cond
                 ((stringp status)
                  (error "(clang-format killed by signal %s%s)" status stderr))
                 ((not (equal 0 status))
                  (error "(clang-format failed with code %d%s)" status stderr)))

                (with-current-buffer temp-buffer
                  (setq operations (clang-format--extract (car (xml-parse-region)))))

                (let ((replacements (nth 0 operations))
                      (cursor (nth 1 operations))
                      (incomplete-format (nth 2 operations)))
                  (save-excursion
                    (mapc (lambda (rpl)
                            (apply #'clang-format--replace rpl))
                          replacements))
                  (when cursor
                    (goto-char (byte-to-position (1+ cursor))))
                  (message "%s" incomplete-format)
                  (if incomplete-format
                      (message "(clang-format: incomplete (syntax errors)%s)" stderr)
                    (message "(clang-format: success%s)" stderr))))
            (delete-file temp-file)
            (when (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
      (bind-key "C-M-\\" 'clang-format-region c++-mode-map)
      (bind-key "C-i" 'clang-format c++-mode-map))
    (font-lock-add-keywords
     nil
     '((my-c-mode-font-lock-if0 (0 font-lock-comment-face prepend))) 'add-to-end)
