aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/rul-lisp/packages/rul-write.el
blob: 719baaf3b96caed995b39162583b85400cf216dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;;; `dictionary'
(setq dictionary-server "dict.org"
      dictionary-default-popup-strategy "lev"
      dictionary-create-buttons nil
      dictionary-use-single-buffer t)
(define-key global-map (kbd "C-c d") #'dictionary-lookup-definition)

(use-package denote
  :ensure t
  :hook (dired-mode . denote-dired-mode)
  :bind
  (("C-c n n" . denote)
   ("C-c n r" . denote-rename-file)
   ("C-c n l" . denote-link)
   ("C-c n b" . denote-backlinks))
  :config
  (denote-rename-buffer-mode 1)
  (setq denote-infer-keywords t)
  (setq denote-sort-keywords t)
  (setq denote-file-type 'org)
  (setq denote-excluded-directories-regexp nil)
  (setq denote-allow-multi-word-keywords nil)
  (setq denote-link-fontify-backlinks t)
  (setq denote-rename-no-confirm t)

  (let ((map global-map))
    (define-key map (kbd "C-c n j") #'rul/denote-journal)
    (define-key map (kbd "C-c n n") #'denote)
    (define-key map (kbd "C-c n f") #'denote-open-or-create)
    (define-key map (kbd "C-c n i") #'denote-link)
    (define-key map (kbd "C-c n r") #'denote-rename-file)
    )
)

(defun rul/denote-journal ()
  "Create an entry tagged 'journal' with the date as its title.
If a journal for the current day exists, visit it.  If multiple
entries exist, prompt with completion for a choice between them.
Else create a new file."
  (interactive)
  (let* ((today (format-time-string "%A %e %B %Y"))
         (string (denote-sluggify today "title"))
         (files (denote-directory-files-matching-regexp string)))
    (cond
     ((> (length files) 1)
      (find-file (completing-read "Select file: " files nil :require-match)))
     (files
      (find-file (car files)))
     (t
      (denote
       today
       '("journal"))))))

;; auto-fill mode
(add-hook 'text-mode-hook 'turn-on-auto-fill)

;; Flycheck
(use-package flycheck
  :ensure t
  :config

(flycheck-define-checker proselint
  "A linter for prose."
  :command ("proselint" source-inplace)
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": "
	    (id (one-or-more (not (any " "))))
	    (message) line-end))
  :modes (text-mode markdown-mode gfm-mode org-mode))

(add-to-list 'flycheck-checkers 'proselint)

;; TODO: docker run --rm -p 8010:8010 erikvl87/languagetool
(use-package flycheck-languagetool
  :ensure t
  :hook (message-mode . flycheck-languagetool-setup)
  :init
  (setq flycheck-languagetool-url "http://localhost:8010")
))

;; Flyspell
(defcustom flyspell-delayed-commands nil
  "List of commands that are \"delayed\" for Flyspell mode.
After these commands, Flyspell checking is delayed for a short time,
whose length is specified by `flyspell-delay'."
  :group 'flyspell
  :type '(repeat (symbol)))

(setq ispell-dictionary "en")
(setq flyspell-default-dictionary "en")

(setq flyspell-issue-welcome-flag nil)
(setq-default ispell-list-command "list")

(provide 'rul-write)
nihil fit ex nihilo