 ;; (global-set-key (kbd "M-M") #'jump-char-backward)
 
 (global-set-key [remap fill-paragraph] #'unfill-toggle)
-
-(define-key helm-map (kbd "C-'") 'ace-jump-helm-line-execute-action)
 
 (defun dired-back-to-top ()
   (interactive)

  (exec-path-from-shell-initialize)
  (setq python-shell-completion-native-enable nil))

(require 'helm)
(require 'helm-config)
(helm-mode 1)   ;; completion-read etc..
(diminish 'helm-mode)

(setq helm-candidate-number-limit 100)
(setq helm-buffer-max-length 32)
;; (helm-push-mark-mode 1)

(advice-add 'helm-ff-filter-candidate-one-by-one     ;; skip ".." pattern (C-l)
            :around (lambda (fcn file)
                      (unless (string-match "\\(?:/\\|\\`\\)\\.\\{2\\}\\'" file)
                        (funcall fcn file))))

(add-hook 'helm-grep-mode-hook 'grep-mode)
(setq helm-grep-save-buffer-name-no-confirm 1)

(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z") 'helm-select-action)

;; (require 'helm-dabbrev)
;; (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)

(global-set-key [remap list-buffers] 'helm-buffers-list)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x b") 'helm-buffers-list)
(global-set-key (kbd "C-h a") 'helm-apropos)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-set-key (kbd "C-c <SPC>") 'helm-all-mark-rings)
(global-set-key (kbd "C-c C-r") 'helm-resume)

;; (setq helm-ag-command-option "--smart-case")

(autoload 'helm-swoop "helm-swoop")
(with-eval-after-load 'helm-swoop
  (define-key helm-swoop-map (kbd "C-r") 'helm-previous-line)
  (define-key helm-swoop-map (kbd "C-s") 'helm-next-line))
(global-set-key (kbd "M-i") 'helm-swoop)

(setq projectile-enable-caching t)
(projectile-global-mode)
(diminish 'projectile-mode)

(setq helm-projectile-fuzzy-match nil)
(add-to-list 'projectile-globally-ignored-files ".DS_Store")
(setq projectile-completion-system 'helm)
(helm-projectile-on)

(require 'helm-for-files)    ;; helm-source-recentf

(defun my-helm-projectile-buffers-list ()
  (interactive)
  (unless helm-source-buffers-list
    (setq helm-source-buffers-list
          (helm-make-source "Buffers" 'helm-source-buffers)))
  (helm :sources '(helm-source-buffers-list
                   helm-source-projectile-recentf-list
                   helm-source-projectile-files-list
                   helm-source-recentf
                   helm-source-buffer-not-found)
        :buffer "*helm buffers*"
        :keymap helm-buffer-map
        :truncate-lines helm-buffers-truncate-lines))

(require 'helm-grep)

;; (when (not (kelly?))
;;   (setq helm-grep-ag-command "rg --smart-case --no-heading --line-number %s %s %s"))

(global-set-key (kbd "M-g") (lambda ()
                              (interactive)
                              (helm-grep-ag (projectile-project-root) nil)))

(global-set-key (kbd "M-G") (lambda ()
                              (interactive)
                              (helm-grep-ag (helm-current-directory) nil)))

(global-set-key (kbd "C-c C-f") 'helm-projectile-find-file)
(global-set-key (kbd "C-x b") 'my-helm-projectile-buffers-list)

(global-set-key (kbd "C-h f") 'helpful-function)
(global-set-key (kbd "C-h F") 'helpful-command)

  (set-face-attribute 'rtags-errline
                      nil
                      :background "#eeb0b0"))


(defun my-imenu ()
  (interactive)
  (if (rtags-is-indexed)
      (rtags-imenu)
    (imenu)))             ;; TODO: counsel-imenu-in-all-buffers -> imenu-anywhere (ivy)

(defun my-non-special-modes-setup ()
  (setq indicate-empty-lines t)
