#+TITLE: Deft layer

#+TAGS: layer|reader

* Table of Contents                     :TOC_5_gh:noexport:
- [[#description][Description]]
  - [[#features][Features:]]
- [[#install][Install]]
  - [[#layer][Layer]]
  - [[#zetteldeft][Zetteldeft]]
  - [[#configuration][Configuration]]
- [[#key-bindings][Key bindings]]
  - [[#zetteldeft-key-bindings][Zetteldeft key bindings]]
    - [[#global][Global]]
    - [[#org-mode][Org-mode]]

* Description
This layer adds a search driven note taking system into Spacemacs.

** Features:
- Browsing and creating notes with a powerful search function via [[http://jblevins.org/projects/deft/][Deft]].
- Integration of =org-mode= as note editor.
- Configurable list of extensions to recognize as notes.
- Zettelkasten system with [[https://github.com/EFLS/zetteldeft][zetteldeft]]

* Install
** Layer
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =deft= to the existing =dotspacemacs-configuration-layers= list in this
file.

** Zetteldeft
Zetteldeft support is included with the layer. To enable it, set the layer variable ~deft-zetteldeft~ to ~t~:

#+BEGIN_SRC elisp
  (deft :variables deft-zetteldeft t)
#+END_SRC

** Configuration
By default deft tries to put notes in =~/.deft= but you can change
this in your =dotspacemacs/user-config= function:

#+BEGIN_SRC emacs-lisp
  (setq deft-directory "~/Dropbox/notes")
#+END_SRC

By default =Deft= uses filenames for note titles and =org-mode= for editing.
The default extension for new notes is =org=. However also =md= and =txt=
files are recognized as notes. Which extensions are used for notes discovery
can be configured in your =dotfile=:

#+BEGIN_SRC emacs-lisp
  (setq deft-extensions '("org" "md" "txt"))
#+END_SRC

Just add or substitute your preferred extension.

* Key bindings

| Key binding | Description                      |
|-------------+----------------------------------|
| ~SPC a r d~ | Open Deft (works globally)       |
| ~SPC C d~   | Create new file (works globally) |
| ~SPC m c~   | Clear deft filter                |
| ~SPC m d~   | Delete selected note             |
| ~SPC m i~   | Toggle to regex search           |
| ~SPC m n~   | Create new file with filter text |
| ~SPC m N~   | Create new file named            |
| ~SPC m o~   | Deft open file in other window   |
| ~SPC m r~   | Rename selected note             |
| ~SPC m q~   | quit deft window                 |

** Zetteldeft key bindings
Zetteldeft key bindings will appear in a few different places as follows:

*** Global

| Key binding                 | Description                      |
|-----------------------------+----------------------------------|
| ~SPC C z~ / ~SPC a r d z n~ | New zetteldeft file              |
| ~SPC a r d n~               | Open deft (replaces ~SPC a r d~) |
| ~SPC a r d z T~             | Show tag buffer                  |
| ~SPC a r d z s~             | Zetteldeft search-at-point       |
| ~SPC a r d z o~             | Zetteldeft find file             |

*** Org-mode

| Key binding | Description                                |
|-------------+--------------------------------------------|
| ~SPC m z c~ | Search for id of current file              |
| ~SPC m z f~ | Follow link                                |
| ~SPC m z t~ | Tag search with avy                        |
| ~SPC m z N~ | New file and insert link                   |
| ~SPC m z r~ | Rename file                                |
| ~SPC m z i~ | Find a file and insert link                |
| ~SPC m z I~ | Find a file and insert link with full name |
| ~SPC m z s~ | Search at point                            |
| ~SPC m z l~ | Link search with avy                       |
| ~SPC m z F~ | File search with avy on window             |
| ~SPC m z o~ | Find file                                  |
