An personal excerpt manange system on Emacs.
sqlite3
: Database to save excerpts.- dash.el: A modern list API for Emacs.
- f.el: A modern API for working with files and directories in Emacs.
- s.el: The long lost Emacs string manipulation library.
- emacsql: A high-level Emacs Lisp front-end for SQLite.
Clone this to local directory, set load-path
and require
.
(add-to-list 'load-path "/path/to/excerpt")
;; database file
(setq excerpt-database-file "~/.emacs.d/excerpt.db")
(require 'excerpt)
By pressing M-x excerpt
, enter the *Excerpt*
buffer. It shows all the excerpts in buffer.
j/n
(excerpt-next-excerpt
): Move point to next excerpt.k/p
(excerpt-previous-excerpt
): Move point to previous excerpt.l/<tab>
(excerpt-next-tag
): Move point to next tag.h/<backtab>
(excerpt-previous-tag
): Move point to previous tag.a
(excerpt-add-excerpt
): Add a new excerpt. See Adding/Editing/Deleting excerpts.e
(excerpt-edit-excerpt
): Modify excerpt at point. See Adding/Editing/Deleting excerpts.d
(excerpt-delete-excerpt
): Delete exceprt ta point. See Adding/Editing/Deleting excerpts.g
(excerpt-refresh
): Refresh buffer.f
(excerpt-filter-map
): see Filtering.x
(excerpt-database-map
): see Importing/Exporting
There are three ways to filter excerpts: by tags, by date, or by matching content. All the commands should be executed under excerpt-mode
.
Press f a
or M-x excerpt-filter-all
to show all excerpts in database again.
commands: f t
(excerpt-filter-by-tags
)
Tags are read from minibuffer. There are completions for existing tags.
If multiple tags are input, make sure they are separated by comma ,
.
Note that, all the space in the beginning or end of tag will be removed by s-trim
, i.e. " tag1, tag2 3, tag4 "
will become ("tag1" "tag2 3" "tag4")
.
commands: f d
(excerpt-filter-by-date
)
Select a date in minibuffer, then all the excerpts recording in that date show in buffer.
There are completions for date having excerpts.
commands: f s
(excerpt-filter-by-content
)
Input keywords in minibuffer to match the excerpts’ body. Keywords are separated by space.
Now there won’t show completion when inputing strings.
Adding and editing commands invoke a buffer in excerpt-edit-mode
, on which you can operate the content of excerpt.
- A line starting with
;
is considered as comment. - Tags start with
#
, they can stay in one line, or multiple line. C-c C-s
to save the modification.C-c C-k
to discard the modification.C-c C-i
to insert a tag by completing in minibuffer.
Once you modify(or add) an excerpt and save, editing buffer close, and showing buffer refreshes.
When you try to delete an excerpt, there invokes a confirmation, namely you have to input yes-or-no.
Now the external files are supportive only for JSON type. The form is like:
{
data: [
{
content: "cnt",
date: "1970-12-07",
tags: ["t1", "t2", ...]
}, ...
]
}
The whole structure has only one key data
, with an array as value. Each element in the array is a excerpt, consisting of three slots: content
, date
, and tags
, where tags
is another array containing tags’ string.
commands: x i
(excerpt-import
)
Select a file in disk, excerpt.el then parse and append into database, which means it won’t change the data existing in database, and do not care about if there ares duplicate excerpts – It is really hard to tell whether two excerpts are the same.
commands: x e
(excerpt-export
)
Export the excerpts in the buffer to a JSON file. So you have to filter the excerpts you want, then execute exporting.
- [ ] Adding abitary excerpts that are wanted to buffer
- [ ] Allow to override the old data in importing
- [ ] More importing/exporting data type supported
- [ ] Match excerpts’ body by regular expression
- [ ] Custom faces
- [ ] Daily review – Show a random excerpt after Emacs starts, different from each days