 ;;   (global-emojify-mode +1))
 
 (use-package objc-mode
+  :init
+  (defun ar/objc-mode-hook-function ()
+    "Called when entering `objc-mode'."
+    ;; Hook is run twice. Avoid:
+    ;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16759
+    (unless (boundp 'objc-mode-hook-did-run)
+      (ar/clang-format-toggle-automatic)
+      (objc-font-lock-mode)
+      (helm-dash-activate-docset "iOS")
+      (set-fill-column 100)
+
+      (validate-setq company-grep-grep-flags "--type objc --no-line-number --color never --no-filename --smart-case --regexp")
+      (validate-setq company-grep-grep-format-string "^#import\\s*\".*%s")
+      (validate-setq company-grep-grep-trigger "import \"")
+      (validate-setq company-grep-grep-cleanup-fun (lambda (items)
+                                                     (mapcar (lambda (item)
+                                                               (ar/string-match item "import +\"\\(.*\\)\"" 1))
+                                                             items)))
+      (setq-local company-backends '((company-grep company-files company-yasnippet company-keywords company-clang)))
+
+      ;; (setq-local company-backends '((company-rtags)))
+      ;; NOTE: Disabling while trying irony out
+      ;; (setq-local company-backends
+      ;;      ;; List with multiple back-ends for mutual inclusion.
+      ;;      '(( ;;company-ycmd
+      ;;         company-yasnippet
+      ;;         company-gtags
+      ;;         company-dabbrev-code
+      ;;         company-files)))
+      ;;(ycmd-mode)
+      (setq-local objc-mode-hook-did-run t)))
+  :hook (objc-mode . ar/objc-mode-hook-function)
   :bind (:map objc-mode-map
               ([f6] . recompile)))
 

;; More expected region behaviour.
(transient-mark-mode t)

;;  Make a shell script executable automatically on save.
;;  From https://github.com/bbatsov/prelude
(add-hook 'after-save-hook
          'executable-make-buffer-file-executable-if-script-p)

;;  Automatically indent yanked code
;;  From http://www.emacswiki.org/emacs/AutoIndentation#toc3

  :config
  (validate-setq company-tern-meta-as-single-line t))

(use-package js-mode
  :config
  (setq js-indent-level 2))

;; From https://github.com/howardabrams/dot-files/blob/HEAD/emacs-client.org
(use-package color-theme-sanityinc-tomorrow :ensure t)
