2020-05-31 21:14:41 +02:00
#+STARTUP : content
2020-05-31 21:15:17 +02:00
* Table of Contents :TOC_3:
2020-04-10 17:40:46 +02:00
- [[#misc ][Misc ]]
2020-05-31 21:24:27 +02:00
- [[#lexical-bindings ][Lexical bindings ]]
- [[#dir-local-variables ][Dir local variables ]]
2020-05-23 12:55:05 +02:00
- [[#theme ][Theme ]]
2020-05-31 21:24:27 +02:00
- [[#main-theme ][Main theme ]]
2020-05-23 15:33:17 +02:00
- [[#dark-theme-toggle ][Dark theme toggle ]]
2020-04-10 17:40:46 +02:00
- [[#font ][Font ]]
- [[#line-numbers ][Line numbers ]]
2020-04-15 09:52:00 +02:00
- [[#battery-indicator ][Battery indicator ]]
2020-04-10 17:40:46 +02:00
- [[#programming ][Programming ]]
2020-08-03 16:24:17 +02:00
- [[#smart-parens ][Smart parens ]]
2020-04-10 17:40:46 +02:00
- [[#rust ][Rust ]]
2020-08-03 17:08:08 +02:00
- [[#column-width ][Column width ]]
2020-04-10 17:40:46 +02:00
- [[#cc ][C/C++ ]]
2020-05-31 21:24:27 +02:00
- [[#default-style ][Default style ]]
2020-04-10 18:35:06 +02:00
- [[#org-mode ][Org mode ]]
2020-04-27 23:41:49 +02:00
- [[#directory ][Directory ]]
2020-05-23 12:55:31 +02:00
- [[#appearance ][Appearance ]]
2020-05-31 21:24:27 +02:00
- [[#disable-fancy-stars ][Disable fancy stars ]]
- [[#dont-hide-leading-stars ][Don't hide leading stars ]]
- [[#fancier-ellipsis-indicator ][Fancier ellipsis indicator ]]
2020-04-11 16:59:02 +02:00
- [[#agenda-setup ][Agenda setup ]]
2020-05-31 21:24:27 +02:00
- [[#default-task-keywords ][Default task keywords ]]
- [[#org-capture-setup ][Org capture setup ]]
- [[#main-agenda-view ][Main agenda view ]]
- [[#habits ][Habits ]]
2020-06-05 12:46:38 +02:00
- [[#save-all-org-buffers-shortcut ][Save all org buffers shortcut ]]
2020-04-12 20:51:22 +02:00
- [[#org-ids ][Org IDs ]]
2020-04-12 22:50:39 +02:00
- [[#roam ][Roam ]]
2020-05-31 21:24:27 +02:00
- [[#roam-directory ][Roam Directory ]]
- [[#graph-browser ][Graph browser ]]
- [[#roam-link-font-face ][Roam link font face ]]
- [[#roam-capture-template ][Roam capture template ]]
2020-05-31 21:15:17 +02:00
- [[#org-roam-server ][Org Roam Server ]]
2020-05-14 00:52:30 +02:00
- [[#export-backends ][Export backends ]]
2020-04-11 16:59:02 +02:00
- [[#doom-specific ][Doom specific ]]
2020-04-10 17:40:46 +02:00
2020-04-10 17:40:18 +02:00
* Misc
2020-05-31 21:24:27 +02:00
** Lexical bindings
2020-04-10 17:40:18 +02:00
Enable lexical binding, of course...
#+BEGIN_SRC emacs-lisp
;;; -*- lexical-binding: t; -* -
#+END_SRC
2020-05-31 21:24:27 +02:00
** Dir local variables
Disable these because I don't use them and don't want to get prompted by them in
some projects.
2020-04-10 17:40:18 +02:00
#+BEGIN_SRC emacs-lisp
(setq enable-dir-local-variables nil)
#+END_SRC
2020-05-23 12:55:05 +02:00
* Theme
2020-05-31 21:24:27 +02:00
** Main theme
2020-05-23 12:55:05 +02:00
A list of all doom themes can be found here:
https://github.com/hlissner/emacs-doom-themes
#+BEGIN_SRC emacs-lisp
(setq doom-theme 'doom-solarized-light)
#+END_SRC
2020-04-10 16:57:07 +02:00
2020-05-23 15:33:17 +02:00
** Dark theme toggle
I've come to prefer using a light theme during the day, and a dark theme at
night. Using a dark theme with daylight leads to cranking up the screen
brightness, which hurts my eyes more than using the light theme.
Set my light and dark themes:
#+BEGIN_SRC emacs-lisp
(setq my/light-theme doom-theme
my/dark-theme 'doom-one)
#+END_SRC
Function to toggle between the two easily:
#+BEGIN_SRC emacs-lisp
(defun my/toggle-dark-theme ()
(interactive)
(if (eq my/dark-theme doom-theme)
(load-theme my/light-theme t)
(load-theme my/dark-theme t)))
#+END_SRC
Bind this to =SPC t d= :
#+BEGIN_SRC emacs-lisp
(map! :leader
(:prefix-map ("t" . "toggle")
:desc "Dark theme" "d" #'my/toggle-dark-theme))
#+END_SRC
2020-04-10 16:57:07 +02:00
** Font
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:
#+BEGIN_SRC emacs-lisp
2020-04-21 22:03:44 +02:00
(setq doom-font
(font-spec :family "Input Mono Narrow" :size 12 :style 'regular))
2020-04-10 16:57:07 +02:00
#+END_SRC
** Line numbers
Possible values of =display-line-numbers-type= are =nil= , =t= , and ='relative= .
#+BEGIN_SRC emacs-lisp
2020-05-10 00:28:43 +02:00
(setq display-line-numbers-type nil)
2020-04-10 16:57:07 +02:00
#+END_SRC
2020-04-15 09:52:00 +02:00
** Battery indicator
I'm on a laptop, so let's display my battery in the modeline:
#+BEGIN_SRC emacs-lisp
(display-battery-mode 1)
#+END_SRC
2020-04-10 16:57:07 +02:00
* Programming
2020-08-03 16:24:17 +02:00
** Smart parens
Disable smart parens because half of the time it doesn't do what I want:
#+BEGIN_SRC emacs-lisp
(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode)
#+END_SRC
2020-04-10 16:57:07 +02:00
** Rust
2020-08-03 17:08:08 +02:00
*** Column width
2020-06-19 23:17:34 +02:00
=rustfmt= limits lines to 100 characters, let's display it correctly.
#+BEGIN_SRC emacs-lisp
2020-08-03 17:08:08 +02:00
(add-hook! rust-mode
2020-06-19 23:17:34 +02:00
(set-fill-column 100))
#+END_SRC
2020-04-10 16:57:07 +02:00
** C/C++
2020-05-31 21:24:27 +02:00
*** Default style
2020-04-10 16:57:07 +02:00
Setup the default format for C/C++ editing.
#+BEGIN_SRC emacs-lisp
2020-04-21 23:01:10 +02:00
(add-hook! (c-mode c++-mode)
(setq c-default-style "gnu")
(setq c-basic-offset 2))
2020-04-10 16:57:07 +02:00
#+END_SRC
2020-04-10 18:35:06 +02:00
* Org mode
2020-04-27 23:41:49 +02:00
** Directory
Set a default directory for all my org-mode files.
#+BEGIN_SRC emacs-lisp
(setq org-directory "~/org/ ")
#+END_SRC
2020-05-23 12:55:31 +02:00
** Appearance
2020-05-31 21:24:27 +02:00
*** Disable fancy stars
2020-05-23 12:55:31 +02:00
#+BEGIN_SRC emacs-lisp
(remove-hook 'org-mode-hook #'org-superstar-mode)
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Don't hide leading stars
Currently doesn't work due to [[https://github.com/hlissner/doom-emacs/issues/3076 ][hlissner/doom-emacs#3076 ]]
2020-05-23 12:55:31 +02:00
#+BEGIN_SRC emacs-lisp
(after! org
(setq org-hide-leading-stars nil
org-startup-indented nil
org-adapt-indentation nil))
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Fancier ellipsis indicator
2020-05-23 12:55:58 +02:00
#+BEGIN_SRC emacs-lisp
(setq org-ellipsis " ▼ ")
#+END_SRC
2020-04-11 16:59:02 +02:00
** Agenda setup
2020-05-31 21:24:27 +02:00
*** Default task keywords
2020-04-11 23:03:07 +02:00
Here are the [[https://orgmode.org/manual/TODO-Extensions.html#TODO-Extensions ][keywords ]] I'm using to track task progress. I'm also making use of
some automatic [[https://orgmode.org/manual/Tracking-TODO-state-changes.html#Tracking-TODO-state-changes ][state changes ]].
2020-05-23 13:02:17 +02:00
| keyword | meaning |
|-------------+----------------------------------------------------------|
| =TODO= | Self explanatory |
| =DONE= | This task is finished, no longer displayed in the agenda |
| =CANCELLED= | This task isn't finished but is no longer relevant |
2020-04-11 23:03:07 +02:00
#+BEGIN_SRC emacs-lisp
(after! org
(setq org-todo-keywords
'((sequence
"TODO(t)"
"|"
"DONE(d!)"
"CANCELLED(c@/!)")
(sequence
"[ ](T)"
"|"
"[X](D)"))))
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Org capture setup
2020-04-11 23:03:07 +02:00
Of course I also need to setup [[https://orgmode.org/manual/Capture-templates.html ][capture templates ]]:
The first one just prompts me for a new task to add to my inbox, I can then
[[https://orgmode.org/guide/Refile-and-Copy.html ][refile ]] them where I want later.
The second one exists because I like to keep a separate list of articles /
papers / books to read.
2020-04-10 18:35:06 +02:00
#+BEGIN_SRC emacs-lisp
2020-04-11 16:59:02 +02:00
(after! org
2020-04-11 23:03:07 +02:00
(setq org-capture-templates
2020-05-31 21:24:57 +02:00
'(("t" "New entry" entry (file "inbox.org")
"* TODO %?")
2020-08-27 14:35:36 +02:00
("T" "Task" entry (file+headline "tasks.org" "Misc")
2020-04-11 23:03:07 +02:00
"* TODO %?")
("r" "Reading" entry (file "reading.org")
2020-06-19 10:52:26 +02:00
"* TODO %x"
:immediate-finish t)
("w" "Watching" entry (file "watching.org")
2020-04-16 23:25:23 +02:00
"* TODO %x"
:immediate-finish t))))
2020-04-11 23:03:07 +02:00
#+END_SRC
2020-05-31 21:40:10 +02:00
I also change [[https://github.com/hlissner/doom-emacs/blob/134554dd69d9b1cea3d2190422de580fddf40ecd/modules/config/default/%2Bevil-bindings.el#L265 ][the default Doom binding ]] for ~#'org-capture~ to be =SPC x= instead
of =SPC X= . Also need to rebind what was [[https://github.com/hlissner/doom-emacs/blob/134554dd69d9b1cea3d2190422de580fddf40ecd/modules/config/default/%2Bevil-bindings.el#L264 ][previously bound ]] to =SPC x= , to =SPC
X=.
#+BEGIN_SRC emacs-lisp
(map! :leader
:desc "Org Capture" "x" #'org-capture
:desc "Pop up scratch buffer" "X" #'doom/open-scratch-buffer)
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Main agenda view
2020-04-11 23:03:07 +02:00
All these tasks, once captured, are then centralized in my [[https://orgmode.org/guide/Agenda-Views.html ][agenda view ]].
I'm using multiple categories to organize tasks, depending on their triage /
status (inspired by [[https://blog.jethro.dev/posts/org_mode_workflow_preview/ ]]).
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-custom-commands
'((" " "Agenda"
((agenda ""
((org-agenda-span 'day)
(org-agenda-start-day nil)
(org-deadline-warning-days 365)))
(todo "TODO"
((org-agenda-overriding-header "Triage")
(org-agenda-files '("~/org/inbox.org"))))
(todo "TODO"
((org-agenda-overriding-header "School")
(org-agenda-files '(
"~/org/image.org"
"~/org/rdi.org"
2020-05-19 16:01:30 +02:00
))
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline
'scheduled))))
2020-06-03 18:31:28 +02:00
(todo "TODO"
((org-agenda-overriding-header "Assistant")
(org-agenda-files '("~/org/assistant.org"))
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline
'scheduled))))
2020-04-11 23:03:07 +02:00
(todo "TODO"
((org-agenda-overriding-header "Tasks")
(org-agenda-files '("~/org/tasks.org"))
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline
'scheduled))))
2020-06-19 10:52:26 +02:00
(todo "TODO"
((org-agenda-files '("~/org/watching.org"))
(org-agenda-overriding-header "To Watch")))
2020-04-13 18:19:44 +02:00
(todo "TODO"
((org-agenda-files '("~/org/reading.org"))
(org-agenda-overriding-header "To Read")))
2020-07-26 18:04:58 +02:00
(todo "TODO"
((org-agenda-files '("~/org/notes.org"))
(org-agenda-overriding-header "Note Taking")))
2020-04-13 23:32:30 +02:00
(todo "TODO"
((org-agenda-files '("~/org/project.org"))
(org-agenda-overriding-header "Personal projects")))
2020-04-11 23:03:07 +02:00
)))))
#+END_SRC
I want the default agenda view to be a weekly view, with a log of what I've done
during the day.
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-span 'week)
(setq org-agenda-start-on-weekday 1)
(setq org-agenda-start-with-log-mode '(clock)))
#+END_SRC
I also remove the block separators in the agenda view:
#+BEGIN_SRC emacs-lisp
(after! org-agenda
(setq org-agenda-block-separator ""))
2020-04-10 18:35:06 +02:00
#+END_SRC
2020-04-10 18:52:52 +02:00
2020-05-31 21:24:27 +02:00
*** Habits
2020-05-12 10:48:34 +02:00
Let's enable the =org-habit= module:
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-modules 'org-habit)
#+END_SRC
2020-06-05 12:46:38 +02:00
*** Save all org buffers shortcut
By default bound to =C-x C-s= , rebind it to =SPC m s= in =org-agenda-mode= :
#+BEGIN_SRC emacs-lisp
(map! :after org-agenda
:map org-agenda-mode-map
:localleader
"s" #'org-save-all-org-buffers)
#+END_SRC
2020-04-12 20:51:22 +02:00
** Org IDs
Org can link to entries using UUIDs, but we need the module to be loaded for
links to work:
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-modules 'org-id)
#+END_SRC
2020-04-12 22:50:39 +02:00
** Roam
Setup for [[https://github.com/jethrokuan/org-roam ][org-roam ]].
2020-05-31 21:24:27 +02:00
*** Roam Directory
2020-04-12 22:50:39 +02:00
First, set a directory where =org-roam= will index things.
#+BEGIN_SRC emacs-lisp
(setq org-roam-directory (expand-file-name "notes/" org-directory))
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Graph browser
2020-04-30 23:20:44 +02:00
Instruct =org-roam= to use =firefox-developer-edition= to open the graph:
#+BEGIN_SRC emacs-lisp
(setq org-roam-graph-viewer (executable-find "firefox-developer-edition"))
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Roam link font face
2020-05-03 15:01:32 +02:00
Change link color for =org-roam= links, to distinguish them from standard Org
links:
#+BEGIN_SRC emacs-lisp
(after! org-roam
(set-face-attribute 'org-roam-link nil :foreground "#FF8860"))
#+END_SRC
2020-05-31 21:24:27 +02:00
*** Roam capture template
2020-04-12 22:50:39 +02:00
Customize the capture templates:
- the first one is [[https://github.com/jethrokuan/org-roam/blob/772505ba70c073ebc7905c4fcb8b9cc3759c775a/org-roam-capture.el#L81 ][the default one ]], I just removed the timestamp from the file
title.
- the second one I use to create new entries about website links, blog posts,
articles... The ~%x~ in the template is replaced by the content of my X
clipboard, so I just have to copy the website URL before capturing it.
#+BEGIN_SRC emacs-lisp
(after! org-roam
(setq org-roam-capture-templates
'(("d" "default" plain (function org-roam-capture--get-point)
"%?"
:file-name "${slug}"
:head "#+TITLE: ${title}\n"
:unnarrowed t)
2020-05-06 00:22:51 +02:00
("i" "instant" plain (function org-roam-capture--get-point)
"%?"
:file-name "${slug}"
:head "#+TITLE: ${title}\n"
:unnarrowed t
:immediate-finish t)
2020-04-12 22:50:39 +02:00
("w" "website" plain (function org-roam-capture--get-point)
""
:file-name "websites/${slug}"
2020-04-13 18:56:12 +02:00
:head "#+TITLE: ${title}\n#+ROAM_KEY: %x\n"
2020-05-04 16:35:58 +02:00
:unnarrowed t)
("p" "paper" plain (function org-roam-capture--get-point)
"%?"
2020-05-06 00:22:36 +02:00
:file-name "papers/${slug}"
2020-05-04 16:35:58 +02:00
:head "#+TITLE: ${title}\n"
2020-04-12 22:50:39 +02:00
:unnarrowed t))))
#+END_SRC
2020-05-31 21:24:27 +02:00
**** Roam daily capture templates
Also setup daily captures templates, mainly used to store them in a =journal/=
directory instead of at the root.
2020-05-06 00:23:23 +02:00
#+BEGIN_SRC emacs-lisp
(after! org-roam
(setq org-roam-dailies-capture-templates
'(("d" "daily" plain (function org-roam-capture--get-point)
""
:immediate-finish t
:file-name "journal/%<%Y-%m-%d >"
:head "#+TITLE: %<%Y-%m-%d >"))))
#+END_SRC
2020-05-16 01:44:26 +02:00
*** Org Roam Server
2020-05-31 21:24:27 +02:00
=org-roam-server= provides a fancy JS interface to visualize the graph. Just
needs to be loaded, along with its dependency =simple-httpd= .
2020-05-16 01:44:26 +02:00
#+BEGIN_SRC emacs-lisp
(use-package! simple-httpd)
2020-05-18 23:59:50 +02:00
(use-package! org-roam-server)
2020-05-16 01:44:26 +02:00
#+END_SRC
2020-05-14 00:52:30 +02:00
** Export backends
Sometimes I need to export an Org subtree to a file, which is quite easy with
the =org= export backend. It doesn't seem to be enabled by default, so let's add
it to the list:
#+BEGIN_SRC emacs-lisp
(after! org
(add-to-list 'org-export-backends 'org))
#+END_SRC
2020-04-11 16:59:02 +02:00
** Doom specific
Doom replaces the default tab behavior on headings, this restores the default
one. Taken from [[https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/org#hacks ][here ]].
2020-04-10 18:52:52 +02:00
#+BEGIN_SRC emacs-lisp
2020-04-11 16:59:02 +02:00
(after! evil-org
(remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h))
2020-04-10 18:52:52 +02:00
#+END_SRC