Files
org-roam/manual/Deft.html
2020-05-13 11:45:38 +00:00

126 lines
4.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2020-2020 Jethro Kuan <jethrokuan95@gmail.com>
You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any
later version.
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Deft (Org-roam User Manual)</title>
<meta name="description" content="Deft (Org-roam User Manual)">
<meta name="keywords" content="Deft (Org-roam User Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Ecosystem.html#Ecosystem" rel="up" title="Ecosystem">
<link href="Org_002djournal.html#Org_002djournal" rel="next" title="Org-journal">
<link href="Ecosystem.html#Ecosystem" rel="prev" title="Ecosystem">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Deft"></a>
<div class="header">
<p>
Next: <a href="Org_002djournal.html#Org_002djournal" accesskey="n" rel="next">Org-journal</a>, Up: <a href="Ecosystem.html#Ecosystem" accesskey="u" rel="up">Ecosystem</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<hr>
<a name="Deft-1"></a>
<h4 class="subsection">13.2.1 Deft</h4>
<p><a href="https://jblevins.org/projects/deft/">Deft</a> provides a nice interface
for browsing and filtering org-roam notes.
</p>
<div class="lisp">
<pre class="lisp">(use-package deft
:after org
:bind
(&quot;C-c n d&quot; . deft)
:custom
(deft-recursive t)
(deft-use-filter-string-for-filename t)
(deft-default-extension &quot;org&quot;)
(deft-directory &quot;/path/to/org-roam-files/&quot;))
</pre></div>
<p>If the title of the Org file is not the first line, you might not get
nice titles. You may choose to patch this to use &lsquo;<samp>org-roam</samp>&rsquo;&rsquo;s
functionality. Here I&rsquo;m using
<a href="https://github.com/raxod502/el-patch">el-patch</a>:
</p>
<div class="lisp">
<pre class="lisp">(use-package el-patch
:straight (:host github
:repo &quot;raxod502/el-patch&quot;
:branch &quot;develop&quot;))
(eval-when-compile
(require 'el-patch))
(use-package deft
;; same as above...
:config/el-patch
(defun deft-parse-title (file contents)
&quot;Parse the given FILE and CONTENTS and determine the title.
If `deft-use-filename-as-title' is nil, the title is taken to
be the first non-empty line of the FILE. Else the base name of the FILE is
used as title.&quot;
(el-patch-swap (if deft-use-filename-as-title
(deft-base-filename file)
(let ((begin (string-match &quot;^.+$&quot; contents)))
(if begin
(funcall deft-parse-title-function
(substring contents begin (match-end 0))))))
(org-roam--get-title-or-slug file))))
</pre></div>
<p>The Deft interface can slow down quickly when the number of files get
huge. <a href="https://github.com/hasu/notdeft">Notdeft</a> is a fork of Deft
that uses an external search engine and indexer.
</p>
</body>
</html>