 
 (add-hook 'prog-mode-hook 'my-prog-modes-hook)
 
-;; (require 'helm-xref)
-;; (setq xref-show-xrefs-function 'helm-xref-show-xrefs)
+(require 'helm-xref)
+(setq xref-show-xrefs-function 'helm-xref-show-xrefs)
 
 (defun run-s7 ()
   (interactive)


(global-set-key [remap fill-paragraph] #'unfill-toggle)

(defun dired-back-to-top ()
  (interactive)
  (beginning-of-buffer)

(diminish 'projectile-mode)

(add-to-list 'projectile-globally-ignored-files ".DS_Store")

(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)

(setq projectile-completion-system 'helm)
(helm-projectile-on)
(setq helm-projectile-fuzzy-match nil)

(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))

(global-set-key [remap list-buffers] 'my-helm-projectile-buffers-list)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x b") 'my-helm-projectile-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)

(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)

(require 'helm-grep)

(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-h f") 'helpful-function)
(global-set-key (kbd "C-h v") 'helpful-variable)
