  delete-trailing-lines nil
  fill-column 80
  sentence-end-double-space nil
+ word-wrap t
  ;; Scrolling
  hscroll-margin 1
  hscroll-step 1


;; Branching & persistent undo
(def-package! undo-tree
  :init
  (add-transient-hook! 'find-file-hook (require 'undo-tree))
  :config
  (setq undo-tree-auto-save-history t
        undo-tree-history-directory-alist (list (cons "." (concat doom-cache-dir "undo-tree-hist/"))))

  (defun doom*silent-undo-tree-load-history-hook (orig-fn &rest args)
    "Silence undo-tree load errors."
    (quiet! (apply orig-fn args)))
  (advice-add #'undo-tree-load-history-hook :around #'doom*silent-undo-tree-load-history-hook))

;; Keep track of recently opened files
(def-package! recentf
  :defer 1
  :config
  (setq recentf-save-file (concat doom-cache-dir "recentf")
        recentf-exclude (list "/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$"
                              "^/var/folders/.+$" doom-local-dir)
        recentf-max-menu-items 0
        recentf-max-saved-items 250
        recentf-filename-handlers '(abbreviate-file-name))
  (quiet! (recentf-mode 1)))


;;

 ;; Wrapping
 truncate-lines t
 truncate-partial-width-windows 50
 ;; undo-tree
 undo-tree-auto-save-history t
 undo-tree-history-directory-alist (list (cons "." (concat doom-cache-dir "undo-tree-hist/")))
 visual-fill-column-center-text nil
 vc-follow-symlinks t)

;; ediff: use existing frame instead of creating a new one
(add-hook! 'ediff-load-hook
  (setq ediff-diff-options           "-w"
        ediff-split-window-function  #'split-window-horizontally
        ediff-window-setup-function  #'ediff-setup-windows-plain)) ; no extra frames

(defun doom|dont-kill-scratch-buffer ()
  "Don't kill the scratch buffer."
  (or (not (string= (buffer-name) "*scratch*"))
      (ignore (bury-buffer))))
(add-hook 'kill-buffer-query-functions #'doom|dont-kill-scratch-buffer)

(defun doom*delete-trailing-whitespace (orig-fn &rest args)
  "Don't affect trailing whitespace on current line."
