;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!

;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Dorian Wood"
      user-mail-address "dorian@threeraccoons.com")

;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;;   presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;;       doom-variable-pitch-font (font-spec :family "sans" :size 13))
(setq doom-font (font-spec :family "Iosevka Term" :size 20 :weight 'semi-light)
      doom-variable-pitch-font (font-spec :family "Iosevka Term"))
;; This does some other things with fonts that I like, mainly unsets the dark
;; background and changes the font size properly
;; (custom-set-faces '(default ((t (:height 120)))))

;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-fairy-floss)
;;(setq doom-theme 'doom-one)

;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")

;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)

;; Setting transparency
;;(set-frame-parameter (selected-frame) 'alpha '(<active> [<inactive>]))
(set-frame-parameter (selected-frame) 'alpha '(100 50))
(add-to-list 'default-frame-alist '(alpha 100 50))
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;;   this file. Emacs searches the `load-path' when you load packages with
;;   `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
;; Set the default browser to emacs-w3m
(setq browse-url-browser-function `w3m-browse-url)
;; (setq browse-url-browser-function `browse-url-xdg-open)
(autoload `w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; Turn off line highlighting.
;; (global-hl-line-mode -1)

(defun copy-all ()
  "Copy entire buffer to clipboard"
  (interactive)
      (clipboard-kill-ring-save (point-min) (point-max)))
;; Use xclip.el to synce emacs kill buffer with x system clipboard
(xclip-mode 1)

(defun date ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d")))

(defun time ()
  (interactive)
  (insert (concat "Entry Time: " (format-time-string "%H:%M:%S"))))

(defun open-diary ()
  (interactive)
  (find-file(concat "~/wrt/diary/" (format-time-string "%Y-%m-%d") ".md")))

;; Initialize elfeed-org
;; This hooks up elfeed-org to read the configuration when elfeed
;; is started with =M-x elfeed=
(elfeed-org)
(setq elfeed-db-directory "~/.config/doom/elfeed/data")
(setq rmh-elfeed-org-files '("~/.config/doom/elfeed/elfeed.org"))
;;functions to support syncing .elfeed between machines
;;makes sure elfeed reads index from disk before launching
(defun bjm/elfeed-load-db-and-open ()
  "Wrapper to load the elfeed db from disk before opening"
  (interactive)
  (elfeed-db-load)
  (elfeed)
  (elfeed-search-update--force))

;;write to disk when quiting
(defun bjm/elfeed-save-db-and-bury ()
  "Wrapper to save the elfeed db to disk before burying buffer"
  (interactive)
  (elfeed-db-save)
  (quit-window))
(map! :leader
;; Set up leader keys for use with elfeed
      (:prefix-map ("e" . "elfeed")
       :desc "Switch to Elfeed buffer"  "f" #'elfeed
       :desc "Update Feeds"             "u" #'elfeed-update
       :desc "Save db"                  "q" #'bjm/elfeed-save-db-and-bury
       :desc "Next Item"                "n" #'elfeed-show-next)
;; Set a toggle for disabling evil mode. It sometimes interferes with stuff
      (:prefix-map ("t" . "toggle")
       :desc "Turn off Evil-Mode"       "e" #'turn-off-evil-mode)
;; Some personal journaling functions
      (:prefix-map ("d" . "diary")
       :desc "Open Today's diary"       "o" #'open-diary
       :desc "Entry Time line"          "t" #'time
       :desc "Date"                     "d" #'date))

;; Apparently pdf-tools needs to be compiled every time we start emacs
(pdf-tools-install)

;; Set up SLIME for fscking around with LISP
(load (expand-file-name "~/.quicklisp/slime-helper.el"))
(setq inferior-lisp-program "sbcl")

;; Enable fast copy/move in dired when two windows are open
(setq dired-dwim-target t)

;; Set subproccess connection type. Otherwise org links to pdf files don't launch the pdf viewer.
(setq process-connection-type nil)
