   :straight t
   :commands (elfeed elfeed-update):init
   (progn
-    (run-at-time nil
+    (run-at-time "1 hour"
+                                        ; first run after 1 hour
                  (* 6 60 60)
                  (lambda ()
                    (elfeed-update)
-                   (elfeed-db-save))))
-  :init (evil-leader/set-key "a e" 'elfeed):config
-  (progn
-    (setq elfeed-sort-order 'ascending)
-    (setq browse-url-browser-function '(lambda (url &rest args)
-                                         (interactive)
-                                         (start-process "*open*" "*open*" "open" "-g"
-                                                        url)
-                                         (message "Opened %s" url)))
-    (setq browse-url-generic-program "open")
-    (setq browse-url-generic-args (list "-g"))
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "o")
-      (lambda ()
-        (interactive)
-        (elfeed-search-browse-url t)))
-    (evil-define-key 'visual
-      elfeed-search-mode-map
-      (kbd "o")
-      'elfeed-search-browse-url)
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "d")
-      'meain/elfeed-search-filter)
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "c")
-      'meain/elfeed-search-filter-by-name)
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "D")
-      (lambda ()
-        (interactive)
-        (setq elfeed-search-filter "@2-months-ago +unread")
-        (elfeed-search-update :force)))
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "q")
-      'elfeed-db-unload)
-    (defun meain/elfeed-open-all ()
-      (interactive)
-      (with-current-buffer "*elfeed-search*"
-        (cl-loop for
-                 entry
-                 in
-                 elfeed-search-entries
-                 collect
-                 (browse-url (elfeed-entry-link entry))))
-      (elfeed-untag elfeed-search-entries 'unread)
-      (mapc #'elfeed-search-update-entry elfeed-search-entries))
-    (evil-define-key 'normal
-      elfeed-search-mode-map
-      (kbd "O")
-      'meain/elfeed-open-all)
-    (defun meain/elfeed-search-filter ()
-      (interactive)
-      (setq elfeed-search-filter "@2-months-ago +unread")
-      (elfeed-search-update :force)
-      (let ((tag (completing-read "Apply tag: "
-                                  (remove-if (lambda (x)
-                                               (equalp x 'unread))
-                                             (delete-dups (flatten-list (cl-list* (with-current-buffer "*elfeed-search*"
-                                                                                    (cl-loop for
-                                                                                             entry
-                                                                                             in
-                                                                                             elfeed-search-entries
-                                                                                             collect
-                                                                                             (elfeed-entry-tags entry)))))))
-                                  nil
-                                  t
-                                  "\\.")))
-        (setq elfeed-search-filter (concatenate 'string "@2-months-ago +unread +"
-                                                tag))
-        (elfeed-search-update :force)
-        (evil-goto-first-line)))
-    (defun meain/elfeed-search-filter-by-name ()
-      (interactive)
-      (setq elfeed-search-filter (mapconcat 'identity
-                                            (remove-if-not (lambda (x)
-                                                             (or (string-prefix-p "+" x)
-                                                                 (string-prefix-p "@" x)))
-                                                           (split-string elfeed-search-filter))
-                                            " "))
-      (elfeed-search-update :force)
-      (let ((site (completing-read "Look for: "
-                                   (remove-if (lambda (x)
-                                                (equalp x 'unread))
-                                              (delete-dups (flatten-list (cl-list* (with-current-buffer "*elfeed-search*"
-                                                                                     (cl-loop for
-                                                                                              entry
-                                                                                              in
-                                                                                              elfeed-search-entries
-                                                                                              collect
-                                                                                              (cl-struct-slot-value (type-of (elfeed-entry-feed (car elfeed-search-entries)))
-                                                                                                                    'title
-                                                                                                                    (elfeed-entry-feed entry)))))))))))
-        ;; Need \s- insted of just a simple space because elfeed has issues with space in title
-        (setq elfeed-search-filter (concatenate 'string
-                                                elfeed-search-filter
-                                                " ="
-                                                (mapconcat 'identity
-                                                           (split-string site)
-                                                           "\\s-")))
-        (elfeed-search-update :force)
-        (evil-goto-first-line)))
-    (setq-default elfeed-search-filter "@2-months-ago +unread ")
-    (setq elfeed-use-curl t)
-    (setq elfeed-curl-max-connections 10)
-    (setq elfeed-db-directory "~/.config/emacs/elfeed/")
-    (setq elfeed-enclosure-default-dir "~/Downloads/")
-    (add-to-list 'display-buffer-alist
-                 '((lambda (bufname _)
-                     (with-current-buffer bufname
-                       (equal major-mode 'elfeed-show-mode)))
-                   (display-buffer-reuse-window display-buffer-at-bottom)
-                   (reusable-frames . visible)
-                   (window-height . 0.7)))
-    (defun meain/elfeed-search-print (entry)
-      "Print ENTRY to the buffer."
-      (let* ((feed-width 25)
-             (tags-width 50)
-             (title (or (elfeed-meta entry :title)
-                        (elfeed-entry-title entry)
-                        ""))
-             (title-faces (elfeed-search--faces (elfeed-entry-tags entry)))
-             (feed (elfeed-entry-feed entry))
-             (feed-title (when feed
-                           (or (elfeed-meta feed :title)
-                               (elfeed-feed-title feed))))
-             (tags (mapcar #'symbol-name
-                           (elfeed-entry-tags entry)))
-             (tags-str (concat " ("
-                               (mapconcat 'identity tags ",")
-                               ")"))
-             (title-width (- (window-width)
-                             feed-width
-                             tags-width
-                             4))
-             (title-column (elfeed-format-column title
-                                                 (elfeed-clamp elfeed-search-title-min-width
-                                                               title-width elfeed-search-title-max-width)
-                                                 :left))
-             (tag-column (elfeed-format-column tags-str
-                                               (elfeed-clamp (length tags-str)
-                                                             tags-width
-                                                             tags-width)
-                                               :left))
-             (feed-column (elfeed-format-column feed-title
-                                                (elfeed-clamp feed-width feed-width feed-width)
-                                                :left)))
-        (insert (propertize feed-column 'face 'elfeed-search-feed-face)
-                " ")
-        (insert (propertize title 'face title-faces 'kbd-help
-                            title))
-        (insert (propertize tag-column 'face 'elfeed-search-tag-face)
-                " ")))
-    (setq elfeed-search-print-entry-function 'meain/elfeed-search-print)
-    (defun meain/elfeed-display-buffer (buf &optional act &rest _)
-      (pop-to-buffer buf))
-    (setq elfeed-show-entry-switch #'meain/elfeed-display-buffer)
-    (defun meain/elfeed-show-next-prev (&optional prev)
-      "Go to next elfeed entry.  Pass PREV to switch to prev entry."
-      (interactive)
-      (if (equal (buffer-name) "*elfeed-entry*")
-          (delete-window))
-      (switch-to-buffer "*elfeed-search*")
-      (if prev
-          (previous-line 2))
-      (pulse-momentary-highlight-one-line (point))
-      (call-interactively 'elfeed-search-show-entry))
-    (evil-define-key 'normal
-      elfeed-show-mode-map
-      (kbd "M-n")
-      'meain/elfeed-show-next-prev)
-    (evil-define-key 'normal
-      elfeed-show-mode-map
-      (kbd "M-p")
-      (lambda ()
-        (interactive)
-        (meain/elfeed-show-next-prev t)))
-    (defun meain/elfeed-enclosure-download (base-dir extension)
-      "Download podcast to `BASE-DIR' with proper heirary using feed and title using `EXTENSION'"
-      (start-process "*elfeed-enclosure-download*"
-                     "*elfeed-enclosure-download*"
-                     "downloader"
-                     (elt (car (elfeed-entry-enclosures elfeed-show-entry))
-                          0)
-                     (format "%s/%s/%s%s"
-                             base-dir
-                             (elfeed-feed-title (elfeed-entry-feed elfeed-show-entry))
-                             (elfeed-entry-title elfeed-show-entry)
-                             extension))
-      (message "Download started for %s - %s"
-               (elfeed-feed-title (elfeed-entry-feed elfeed-show-entry))
-               (elfeed-entry-title elfeed-show-entry)))
-    (defun meain/elfeed-podcast-download-to-local ()
-      "Download current feed(podcast) to usual dir."
-      (interactive)
-      (meain/elfeed-enclosure-download "/Users/meain/Desktop/newsboat/podcasts"
-                                       ".mp3"))
-    (load-file "~/.config/emacs/elfeed-feeds.el")))
+                   (elfeed-db-save)))
+    (evil-leader/set-key "a e" 'elfeed))
+  :config (progn
+            (setq elfeed-sort-order 'ascending)
+            (setq browse-url-browser-function '(lambda (url &rest args)
+                                                 (interactive)
+                                                 (start-process "*open*" "*open*" "open" "-g"
+                                                                url)
+                                                 (message "Opened %s" url)))
+            (setq browse-url-generic-program "open")
+            (setq browse-url-generic-args (list "-g"))
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "o")
+              (lambda ()
+                (interactive)
+                (elfeed-search-browse-url t)))
+            (evil-define-key 'visual
+              elfeed-search-mode-map
+              (kbd "o")
+              'elfeed-search-browse-url)
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "d")
+              'meain/elfeed-search-filter)
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "c")
+              'meain/elfeed-search-filter-by-name)
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "D")
+              (lambda ()
+                (interactive)
+                (setq elfeed-search-filter "@2-months-ago +unread")
+                (elfeed-search-update :force)))
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "q")
+              'elfeed-db-unload)
+            (defun meain/elfeed-open-all ()
+              (interactive)
+              (with-current-buffer "*elfeed-search*"
+                (cl-loop for
+                         entry
+                         in
+                         elfeed-search-entries
+                         collect
+                         (browse-url (elfeed-entry-link entry))))
+              (elfeed-untag elfeed-search-entries 'unread)
+              (mapc #'elfeed-search-update-entry elfeed-search-entries))
+            (evil-define-key 'normal
+              elfeed-search-mode-map
+              (kbd "O")
+              'meain/elfeed-open-all)
+            (defun meain/elfeed-search-filter ()
+              (interactive)
+              (setq elfeed-search-filter "@2-months-ago +unread")
+              (elfeed-search-update :force)
+              (let ((tag (completing-read "Apply tag: "
+                                          (remove-if (lambda (x)
+                                                       (equalp x 'unread))
+                                                     (delete-dups (flatten-list (cl-list* (with-current-buffer "*elfeed-search*"
+                                                                                            (cl-loop for
+                                                                                                     entry
+                                                                                                     in
+                                                                                                     elfeed-search-entries
+                                                                                                     collect
+                                                                                                     (elfeed-entry-tags entry)))))))
+                                          nil
+                                          t
+                                          "\\.")))
+                (setq elfeed-search-filter (concatenate 'string "@2-months-ago +unread +"
+                                                        tag))
+                (elfeed-search-update :force)
+                (evil-goto-first-line)))
+            (defun meain/elfeed-search-filter-by-name ()
+              (interactive)
+              (setq elfeed-search-filter (mapconcat 'identity
+                                                    (remove-if-not (lambda (x)
+                                                                     (or (string-prefix-p "+" x)
+                                                                         (string-prefix-p "@" x)))
+                                                                   (split-string elfeed-search-filter))
+                                                    " "))
+              (elfeed-search-update :force)
+              (let ((site (completing-read "Look for: "
+                                           (remove-if (lambda (x)
+                                                        (equalp x 'unread))
+                                                      (delete-dups (flatten-list (cl-list* (with-current-buffer "*elfeed-search*"
+                                                                                             (cl-loop for
+                                                                                                      entry
+                                                                                                      in
+                                                                                                      elfeed-search-entries
+                                                                                                      collect
+                                                                                                      (cl-struct-slot-value (type-of (elfeed-entry-feed (car elfeed-search-entries)))
+                                                                                                                            'title
+                                                                                                                            (elfeed-entry-feed entry)))))))))))
+                ;; Need \s- insted of just a simple space because elfeed has issues with space in title
+                (setq elfeed-search-filter (concatenate 'string
+                                                        elfeed-search-filter
+                                                        " ="
+                                                        (mapconcat 'identity
+                                                                   (split-string site)
+                                                                   "\\s-")))
+                (elfeed-search-update :force)
+                (evil-goto-first-line)))
+            (setq-default elfeed-search-filter "@2-months-ago +unread ")
+            (setq elfeed-use-curl t)
+            (setq elfeed-curl-max-connections 10)
+            (setq elfeed-db-directory "~/.config/emacs/elfeed/")
+            (setq elfeed-enclosure-default-dir "~/Downloads/")
+            (add-to-list 'display-buffer-alist
+                         '((lambda (bufname _)
+                             (with-current-buffer bufname
+                               (equal major-mode 'elfeed-show-mode)))
+                           (display-buffer-reuse-window display-buffer-at-bottom)
+                           (reusable-frames . visible)
+                           (window-height . 0.7)))
+            (defun meain/elfeed-search-print (entry)
+              "Print ENTRY to the buffer."
+              (let* ((feed-width 25)
+                     (tags-width 50)
+                     (title (or (elfeed-meta entry :title)
+                                (elfeed-entry-title entry)
+                                ""))
+                     (title-faces (elfeed-search--faces (elfeed-entry-tags entry)))
+                     (feed (elfeed-entry-feed entry))
+                     (feed-title (when feed
+                                   (or (elfeed-meta feed :title)
+                                       (elfeed-feed-title feed))))
+                     (tags (mapcar #'symbol-name
+                                   (elfeed-entry-tags entry)))
+                     (tags-str (concat " ("
+                                       (mapconcat 'identity tags ",")
+                                       ")"))
+                     (title-width (- (window-width)
+                                     feed-width
+                                     tags-width
+                                     4))
+                     (title-column (elfeed-format-column title
+                                                         (elfeed-clamp elfeed-search-title-min-width
+                                                                       title-width elfeed-search-title-max-width)
+                                                         :left))
+                     (tag-column (elfeed-format-column tags-str
+                                                       (elfeed-clamp (length tags-str)
+                                                                     tags-width
+                                                                     tags-width)
+                                                       :left))
+                     (feed-column (elfeed-format-column feed-title
+                                                        (elfeed-clamp feed-width feed-width feed-width)
+                                                        :left)))
+                (insert (propertize feed-column 'face 'elfeed-search-feed-face)
+                        " ")
+                (insert (propertize title 'face title-faces 'kbd-help
+                                    title))
+                (insert (propertize tag-column 'face 'elfeed-search-tag-face)
+                        " ")))
+            (setq elfeed-search-print-entry-function 'meain/elfeed-search-print)
+            (defun meain/elfeed-display-buffer (buf &optional act &rest _)
+              (pop-to-buffer buf))
+            (setq elfeed-show-entry-switch #'meain/elfeed-display-buffer)
+            (defun meain/elfeed-show-next-prev (&optional prev)
+              "Go to next elfeed entry.  Pass PREV to switch to prev entry."
+              (interactive)
+              (if (equal (buffer-name) "*elfeed-entry*")
+                  (delete-window))
+              (switch-to-buffer "*elfeed-search*")
+              (if prev
+                  (previous-line 2))
+              (pulse-momentary-highlight-one-line (point))
+              (call-interactively 'elfeed-search-show-entry))
+            (evil-define-key 'normal
+              elfeed-show-mode-map
+              (kbd "M-n")
+              'meain/elfeed-show-next-prev)
+            (evil-define-key 'normal
+              elfeed-show-mode-map
+              (kbd "M-p")
+              (lambda ()
+                (interactive)
+                (meain/elfeed-show-next-prev t)))
+            (defun meain/elfeed-enclosure-download (base-dir extension)
+              "Download podcast to `BASE-DIR' with proper heirary using feed and title using `EXTENSION'"
+              (start-process "*elfeed-enclosure-download*"
+                             "*elfeed-enclosure-download*"
+                             "downloader"
+                             (elt (car (elfeed-entry-enclosures elfeed-show-entry))
+                                  0)
+                             (format "%s/%s/%s%s"
+                                     base-dir
+                                     (elfeed-feed-title (elfeed-entry-feed elfeed-show-entry))
+                                     (elfeed-entry-title elfeed-show-entry)
+                                     extension))
+              (message "Download started for %s - %s"
+                       (elfeed-feed-title (elfeed-entry-feed elfeed-show-entry))
+                       (elfeed-entry-title elfeed-show-entry)))
+            (defun meain/elfeed-podcast-download-to-local ()
+              "Download current feed(podcast) to usual dir."
+              (interactive)
+              (meain/elfeed-enclosure-download "/Users/meain/Desktop/newsboat/podcasts"
+                                               ".mp3"))
+            (load-file "~/.config/emacs/elfeed-feeds.el")))
 
 ;; command log
 (use-package command-log-mode


;; Winner mode
(use-package winner
  :config (progn
            (global-set-key (kbd "M-f <left>")
                            'winner-undo)

(use-package projectile
  :straight t
  :diminish :commands
  (projectile-switch-project projectile-find-file
                             projectile-project-p)
  :config (progn
            (setq projectile-mode-line "Projectile") ; might speed up tramp
            (projectile-mode 1)
            (setq projectile-sort-order 'recently-active)):init
  (progn
    (evil-leader/set-key "p" 'projectile-switch-project)
    (define-key evil-normal-state-map (kbd "<RET>") (lambda ()
                                                      (interactive)
                                                      (if (projectile-project-p)
                                                          (projectile-find-file)
                                                        (projectile-switch-project))))))

;; ibuffer-projectile
(use-package ibuffer-projectile
  :straight t
  :after (ibuffer projectile):config
  (progn
    (add-hook 'ibuffer-hook
              (lambda ()
                (ibuffer-projectile-set-filter-groups)
                (unless (eq ibuffer-sorting-mode 'alphabetic)
                  (ibuffer-do-sort-by-alphabetic))))
    (setq ibuffer-formats '((mark modified
                                  read-only
                                  " "
                                  (name 18 18 :left :elide)
                                  " "
                                  (size 9 -1 :right)
                                  " "
                                  (mode 16 16 :left :elide)
                                  " "
                                  project-relative-file)))))



