;; Everything relation to navigation (file, buffers, windows .. is here

;; With fish, there are some troubles to run commands...
;; For example with projectile-find-file...
(setq shell-file-name "/bin/sh")

; remember recent files every 30 minutes
(recentf-mode 1)     
(run-at-time nil (* 30 60) 'recentf-save-list)

;; Show the end of a combination (useful for short memory....)
(use-package which-key
  :init
  (which-key-mode))

;; ------------------- Dired ---------------
;; No details by default, toggle back with (
;; No dotfiles either (activate back with C-x M-o
;; does not work
(use-package dired
  :straight nil			       ; Needed to avoid installing it
  :init
  (setq dired-use-ls-dired nil		; For freebsd
	dired-dwim-target t ; suggest a target for moving/copying intelligently
	dired-listing-switches "-alh" ; Human readable size
	)
  :bind (:map dired-mode-map
	      (("ê" . dired-do-async-shell-command)
	       ("è" . dired-up-directory)))
  ;; For wdired, use C-x C-q (builtin)
  )

:root-dir
(use-package dired-x  			; Dired-x is needed to omit 
   :straight nil 			; Needed to avoid installing it
   :config
   (setq dired-omit-files
	 (concat dired-omit-files "\\|^\\..+$"))
   :hook
   ((dired-mode . dired-hide-details-mode) ; No details
    (dired-mode . dired-omit-mode) ; No details
    ))

;; Open movies and ebooks in dired
(use-package openwith
  :config
  (openwith-mode 1)
  (add-hook 'dired-mode-hook 'openwith-mode 1)
  (setq openwith-associations
	(list
	 ;; (list (openwith-make-extension-regexp '("pdf" "epub"))
	 (list (openwith-make-extension-regexp '("epub"))
	       "zathura" '(file))
	 (list (openwith-make-extension-regexp '("mkv"))
	       "mpv" '(file))
	 )))

;; -------------- other ------------------
;; Workspaces support: use tab-bar-mode instead (built in)

;; Manage pdfs
(use-package pdf-tools
  :init
  (pdf-loader-install)
  (setq pdf-view-display-size 'fit-height)
  :bind
  (:map pdf-view-mode-map ("M-g g" . pdf-view-goto-page))
  )

;;  Nice modeline (support tab-mode too)
(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1))

(remap-global "C-c e" 'eshell)

;; ------------------- Windows ---------------
;; Use windmove (built-in). Ace-windows is not *that* useful
;; S-left for going left andl so on
(windmove-default-keybindings) 
;; With repeat mode (emacs 28), we can easily switch windows with C-x o then o o o...
(repeat-mode)

;;--------------------- Recentf -----------------
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
(run-at-time nil (* 10 60) 'recentf-save-list) ;; Every 10min