aboutsummaryrefslogtreecommitdiffstats
path: root/config/doom/config.org
blob: 1153a9d243e38ea7e6ccd48e624d53bce266cda1 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#+begin_src emacs-lisp :comments no
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
#+end_src
* Personal information
#+begin_src emacs-lisp
(setq user-full-name "Óscar Nájera"
      user-mail-address (if (string-equal (user-login-name) "on")
                            "oscar.najera@tribe29.com"
                          "hi@oscarnajera.com"))
#+end_src
* Editor
** Theme
#+begin_src emacs-lisp
(setq doom-font (font-spec :family "DejaVuSansMono Nerd Font" :size 18 :weight 'semi-light))
(setq doom-theme 'doom-gruvbox)
#+end_src
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'.
#+begin_src emacs-lisp
;(setq display-line-numbers-type 'relative)
#+end_src
** Package Manager
Doom manages packages separately. Keep that file separate
#+begin_src emacs-lisp :tangle "packages.el"
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el
#+end_src
** SSH agent
#+begin_src emacs-lisp
(if (string-equal (user-login-name) "on")
    (setenv "SSH_AUTH_SOCK" (concat "/run/user/1000/gnupg/S.gpg-agent.ssh"))
  (setenv "SSH_AUTH_SOCK" (concat (getenv "XDG_RUNTIME_DIR")"/gnupg/S.gpg-agent.ssh")))
#+end_src
** Avy
This allows me to jump to buffer positions using my home row ordering
#+begin_src emacs-lisp
(after! avy
  (setq avy-keys '(?r ?t ?i ?e ?a ?o ?n ?s)))
#+end_src
** Ace window
#+begin_src emacs-lisp
(after! ace-window
  (global-set-key (kbd "s-w") 'evil-window-map)
  (setq aw-keys '(?r ?t ?i ?e ?a ?o ?n ?s)))
#+end_src
** Which-key
Because I always need help and it should come up quickly
#+begin_src emacs-lisp
(setq which-key-idle-delay 0.1)
#+end_src
** Smartparens
#+begin_src emacs-lisp
(after! smartparens
  (map!
   :map smartparens-mode-map
   :nvie "C-)" #'sp-forward-slurp-sexp
   :nvie "C-}" #'sp-forward-barf-sexp
   :nvie "C-(" #'sp-backward-slurp-sexp
   :nvie "C-{" #'sp-backward-barf-sexp
   :nie "M-s" #'sp-split-sexp
   :nie "M-j" #'sp-join-sexp)
  (map! :map (emacs-lisp-mode-map scheme-mode-map lisp-mode-map clojure-mode-map)
        :nv ")" #'sp-next-sexp
        :nv "(" #'sp-backward-sexp))
#+end_src
* Dictionary
#+begin_src emacs-lisp :tangle "packages.el"
(package! lexic)
#+end_src
Shamelessly copied from https://tecosaur.github.io/emacs-config/#dictionary
#+begin_src emacs-lisp
(use-package! lexic
  :commands lexic-search lexic-list-dictionary
  :config
  (set-evil-initial-state! 'lexic-mode 'emacs))
#+end_src
#+begin_src emacs-lisp
(defadvice! +lookup/dictionary-definition-lexic (identifier &optional arg)
  "Look up the definition of the word at point (or selection) using `lexic-search'."
  :override #'+lookup/dictionary-definition
  (interactive
   (list (or (doom-thing-at-point-or-region 'word)
             (read-string "Look up in dictionary: "))
         current-prefix-arg))
  (lexic-search identifier nil nil t))
#+end_src
* Orgmode
#+begin_src emacs-lisp
(after! org
  (setcdr (assoc "j" org-capture-templates)
          '("Journal" entry (file+olp+datetree +org-capture-journal-file)
            "* %(format-time-string \"%H:%M\") %?\n%a\n%i
- Timebox days

- I am grateful for
- What would make today great
- Daily affirmations
- Amazing things that happened yesterday
- How could I have made yesterday even better?"
            :clock-in t :clock-resume t))

  (add-to-list 'org-capture-templates
               `("e" "Event" entry (file ,(expand-file-name
                                           "caldav.org" org-directory))
                 "* %?\n%^T\n%i\n%a")))
#+end_src
** Alerts
This is to set the reminders of calendar events.
Using appt is quite fine. I get a remainder just above the minibuffer
There is no loud sound or anything disturbing, just the appearance of
this new window.
#+BEGIN_SRC emacs-lisp
(after! org-agenda
  (setq
   appt-display-mode-line t   ;; show in the modeline
   appt-display-format 'echo) ;; use our func
  (run-at-time "5 minutes" (* 3600 2) 'org-agenda-to-appt)
  (appt-activate 1)             ;; active appt (appointment notification)
  (display-time)                ;; time display is required for this...

  ;; update appt each time agenda opened
  (add-hook 'org-agenda-finalize-hook 'org-agenda-to-appt))
#+END_SRC
** Calendar sync
#+begin_src emacs-lisp
(use-package! cal-sync
  :load-path "~/dev/org-caldav"
  :commands (cal-sync-push cal-sync-import-file cal-sync-delete)
  :init (map! :leader
              (:prefix-map "mc"
               "p" #'cal-sync-push
               "f" #'cal-sync-import-file))
  :config
  (setq cal-sync-url "https://cloud.oscarnajera.com/remote.php/dav/calendars/oscar"
        cal-sync-calendar-id "personal"
        org-icalendar-date-time-format ":%Y%m%dT%H%M%SZ"))
#+end_src
* Email
** Notmuch
#+begin_src emacs-lisp :tangle "packages.el"
(package! notmuch)
#+end_src
#+BEGIN_SRC emacs-lisp
(use-package! notmuch
  :init (after! org (add-to-list 'org-modules 'ol-notmuch))
  (map! :leader
        (:prefix-map ("o" . "open")
         :desc "notmuch" "m" #'notmuch))
  :commands notmuch
  :bind (:map notmuch-hello-mode-map
         ("l" . notmuch-jump-search)
         ("/" . notmuch-tree)
         :map notmuch-search-mode-map
         ("f" . notmuch-search-filter-by-tag)
         ("/" . notmuch-tree)
         ("d" . notmuch-search-delete-thread)
         ("D" . notmuch-search-delete-all)
         :map notmuch-show-mode-map
         ("d" . notmuch-show-delete-message)
         ("D" . notmuch-show-delete-thread-then-exit)
         ("i" . notmuch-show-tag-spam)
         ("cr" . org-store-link)
         )
  :config
  (setq-default notmuch-search-oldest-first nil)
  (setq message-directory "~/.mail/"
        message-auto-save-directory "/tmp/"
        org-email-link-description-format "%c: %s")

  (setq notmuch-saved-searches
        '((:name "inbox" :query "tag:inbox" :key "i" :sort-order newest-first)
          (:name "CMK" :query "(tag:CMK-JIRA or tag:lists/gerrit-check_mk) and tag:unread" :key "c")
          (:name "flagged" :query "tag:flagged" :key "f")
          (:name "sent"    :query "tag:sent"    :key "s")
          (:name "unread"  :query "tag:unread" :key "u")
          (:name "drafts"  :query "tag:draft" :key "d")))

  (setq notmuch-show-all-tags-list t
        notmuch-hello-tag-list-make-query "tag:unread and not tag:killed")

  (setq notmuch-fcc-dirs '((".*@oscarnajera.com" . "hi_pers/Sent")
                           ("oscar.najera@tribe29.com" . "work/Sent")
                           ;;(".*@gmail.com" . "\"gmail/[Gmail]/.Sent Mail\"")
                           ))

  (setq notmuch-crypto-process-mime t)
  (setq message-kill-buffer-on-exit t)

  (setq notmuch-archive-tags '("-inbox" "-unread"))

  (setq notmuch-search-line-faces
        `(("deleted" . (:strike-through "red"))
          ("flagged" . notmuch-search-flagged-face)
          ("unread" . notmuch-search-unread-face)))

  (defun notmuch-show-delete-message ()
    "Delete current message if already marked as deleted undo."
    (interactive)
    (apply #'notmuch-show-tag-message
           (if (member "deleted" (notmuch-show-get-tags))
               '("-deleted") '("+deleted" "-inbox" "-unread"))))

  (defun notmuch-show-tag-spam ()
    "Tag spam on current message if already marked as spam undo."
    (interactive)
    (apply #'notmuch-show-tag-message
           (if (member "spam" (notmuch-show-get-tags))
               '("-spam") '("+spam" "-inbox" "-unread"))))

  (defun notmuch-show-delete-thread-then-exit ()
    "Delete all messages in the current buffer, then exit back to search results."
    (interactive)
    (notmuch-show-tag-all '("+deleted"))
    (notmuch-show-next-thread))

  (defun notmuch-search-delete-thread()
    "Delete all messages in the current thread or undelete"
    (interactive)
    (notmuch-search-tag
     (if (member "deleted" (notmuch-search-get-tags))
         '("-deleted")
       '("+deleted" "-inbox" "-unread"))))

  (defun notmuch-search-delete-all()
    "Delete all messages in the current buffer"
    (interactive)
    (notmuch-search-tag-all
     '("+deleted" "-inbox" "-unread")))


  (define-key notmuch-tree-mode-map "d"
    (lambda ()
      "delete message"
      (interactive)
      (notmuch-tree-tag
       (if (member "deleted" (notmuch-tree-get-tags))
           '("-deleted")
         '("+deleted" "-inbox" "-unread"))))))
#+END_SRC
** Sending email
#+begin_src emacs-lisp
(after! notmuch
  (setq send-mail-function 'smtpmail-send-it
        message-send-mail-function 'message-smtpmail-send-it
        smtpmail-local-domain "oscarnajera.com")

  (defun set-smtp-server ()
    (let* ((default-smtp-conf '("default" "mail.oscarnajera.com" 587 starttls "hi"))
           (smtp-from-server-alist
            '(("Oscar Najera <oscar.najera@tribe29.com>"
               "mx.tribe29.com" 587 starttls "on")
              ("Oscar Najera <najera.oscar@gmail.com>"
               "smtp.googlemail.com" 587 starttls "najera.oscar")))
           (smtp-conf (alist-get (save-restriction
                                   (message-narrow-to-headers)
                                   (message-fetch-field "from"))
                                 smtp-from-server-alist default-smtp-conf)))
      (-let [(name server port protocol user) smtp-conf]
        (setq smtpmail-smtp-server server
              smtpmail-smtp-service port
              smtpmail-stream-type protocol
              smtpmail-smtp-user user)
        (message "SMTP server changed to %s in port %s by %s" server port protocol))))

  (add-hook 'message-send-mail-hook 'set-smtp-server))
#+end_src

* Programming languages
** Haskell
#+begin_src emacs-lisp :tangle "packages.el"
(package! hindent)
#+end_src
#+begin_src emacs-lisp
(use-package! hindent
  :hook (haskell-mode . hindent-mode))
#+end_src