 ;; Hit universal arg without ctrl
 (evil-leader/set-key "u" 'universal-argument)
 (global-set-key (kbd "M-u")
-		'universal-argument)
+                'universal-argument)
 
 ;; Eval last sexp
 (evil-leader/set-key "x" 'eval-last-sexp)
 
 ;; Window mappings
 (global-set-key (kbd "M-l")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (evil-window-right 1)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (evil-window-right 1)))
 (global-set-key (kbd "M-h")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (evil-window-left 1)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (evil-window-left 1)))
 (global-set-key (kbd "M-k")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (evil-window-up 1)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (evil-window-up 1)))
 (global-set-key (kbd "M-j")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (evil-window-down 1)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (evil-window-down 1)))
 (global-set-key (kbd "M-b")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (split-window-below)
-		  (windmove-down)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (split-window-below)
+                  (windmove-down)))
 (global-set-key (kbd "M-v")
-		(lambda ()
-		  (interactive)
-		  (evil-force-normal-state)
-		  (split-window-right)
-		  (windmove-right)))
+                (lambda ()
+                  (interactive)
+                  (evil-force-normal-state)
+                  (split-window-right)
+                  (windmove-right)))
 (global-set-key (kbd "M-w")
-		'delete-window)
+                'delete-window)
 (global-set-key (kbd "M-o")
-		(lambda (&optional alternate)
-		  (interactive "P")
-		  (if alternate
-		      (call-interactively 'delete-other-windows)
-		    (other-window 1))))
+                (lambda (&optional alternate)
+                  (interactive "P")
+                  (if alternate
+                      (call-interactively 'delete-other-windows)
+                    (other-window 1))))
 
 ;; Shrink and enlarge windows (not contextual as of now)
 ;; https://www.emacswiki.org/emacs/WindowResize
 (global-set-key (kbd "M-H")
-		'shrink-window-horizontally)
+                'shrink-window-horizontally)
 (global-set-key (kbd "M-L")
-		'enlarge-window-horizontally)
+                'enlarge-window-horizontally)
 (global-set-key (kbd "M-K")
-		'shrink-window)
+                'shrink-window)
 (global-set-key (kbd "M-J")
-		'enlarge-window)
+                'enlarge-window)
 
 ;; File manipulation mappings
 (evil-leader/set-key "<SPC>" 'save-buffer)

  :ensure t
  :commands evil-toggle-fold
  :init (progn
	  (global-origami-mode)
	  (evil-leader/set-key "o" 'evil-toggle-fold)))

;; drag-stuff
(use-package drag-stuff
  :ensure t
  :diminish :commands
  (drag-stuff-up drag-stuff-down drag-stuff-left
		 drag-stuff-right)
  :init (progn
	  (define-key evil-visual-state-map (kbd "<up>") 'drag-stuff-up)
	  (define-key evil-visual-state-map (kbd "<down>") 'drag-stuff-down)
	  (define-key evil-visual-state-map (kbd "<left>") 'drag-stuff-left)
	  (define-key evil-visual-state-map (kbd "<right>") 'drag-stuff-right)):config
  (progn
    (drag-stuff-mode t)
    (drag-stuff-global-mode 1)))

  :ensure t
  :commands notmuch
  :init (progn
          (evil-define-key 'normal
            notmuch-search-mode-map
            (kbd "u")
            'evil-collection-notmuch-search-toggle-unread)
          (evil-define-key 'normal
            notmuch-show-mode-map
            (kbd "u")
            'notmuch-show-browse-urls)
          (evil-define-key 'normal
            notmuch-show-mode-map
            (kbd "M-k")
            (lambda ()
              (interactive)
              (evil-force-normal-state)
              (evil-window-up 1)))
          (evil-define-key 'normal
            notmuch-show-mode-map
            (kbd "M-j")
            (lambda ()
              (interactive)
              (evil-force-normal-state)
              (evil-window-down 1)))
          (evil-leader/set-key "a n" 'notmuch)
          (defun meain/notmuch-show-close-all-but-unread ()
            "Close all messages until the first unread item."
            (interactive)
            (save-excursion
              (goto-char (point-min))
              (cl-loop do
                       (notmuch-show-message-visible (notmuch-show-get-message-properties)
                                                     nil)
                       until
                       (or (not (notmuch-show-goto-message-next))
                           (member "unread" (plist-get (notmuch-show-get-message-properties)
                                                       :tags)))))
            (force-window-update))
          ;; (add-hook 'notmuch-show-mode-hook 'meain/notmuch-show-close-all-but-unread)
          (setq notmuch-search-oldest-first nil)
          (setq notmuch-message-headers-visible nil)
          (setq message-auto-save-directory "/Users/meain/.local/share/mail")
          (setq notmuch-saved-searches (quote ((:name "imbox" :query "tag:imbox AND tag:inbox"
                                                      :key "i"
                                                      :sort-order newest-first)
                                               (:name "meain" :query "query=to:mail@meain.io AND tag:inbox"
                                                      :key "m"
                                                      :sort-order oldest-first)
                                               (:name "github" :query "tag:github AND tag:inbox"
                                                      :key "g"
                                                      :sort-order oldest-first)
                                               (:name "sent" :query "tag:sent"
                                                      :key "s"
                                                      :sort-order newest-first)
                                               (:name "drafts" :query "tag:draft AND tag:inbox"
                                                      :key "d")
                                               (:name "unread" :query "tag:unread AND tag:inbox AND -tag:python"
                                                      :key "u")
                                               (:name "python" :query "tag:python AND tag:inbox"
                                                      :key "p")
                                               (:name "newsletter" :query "tag:newsletter AND tag:inbox"
                                                      :key "n")
                                               (:name "known" :query "tag:known AND tag:inbox"
                                                      :key "k")
                                               (:name "archiveable" :query "tag:bullshit AND tag:known AND tag:nonimportant AND tag:inbox"
                                                      :key "a")
                                               (:name "all mail" :query "*"
                                                      :key "A"
                                                      :sort-order newest-first))))))

;; sending emails
;; (setq message-kill-buffer-on-exit t) ; kill buffer after sending mail
;; (setq mail-specify-envelope-from t) ; Settings to work with msmtp
;; (setq message-sendmail-envelope-from 'header)
;; (setq mail-envelope-from 'header)
;; (setq notmuch-fcc-dirs "G/[Gmail]Sent Mail") ; stores sent mail to the specified directory
;; (setq message-directory "G/[Gmail]Drafts") ; stores postponed messages to the specified directory
(setq sendmail-program "msmtp")
(setq send-mail-function 'smtpmail-send-it)
(setq message-sendmail-f-is-evil t)
(setq message-sendmail-extra-arguments '("--read-envelope-from"))
(setq message-send-mail-function 'message-send-mail-with-sendmail)

;; elfeed
(use-package elfeed
