aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.html419
-rw-r--r--README.md3
-rw-r--r--README.org114
-rw-r--r--README.txt143
-rw-r--r--lib/osugiru.rb5
-rw-r--r--lib/osugiru/database.rb2
-rw-r--r--lib/osugiru/message.rb17
7 files changed, 695 insertions, 8 deletions
diff --git a/README.html b/README.html
new file mode 100644
index 0000000..a4c1b26
--- /dev/null
+++ b/README.html
@@ -0,0 +1,419 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<!-- 2024-11-12 Tue 23:12 -->
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<title>Chotto</title>
+<meta name="author" content="User Mms" />
+<meta name="generator" content="Org Mode" />
+<style>
+ #content { max-width: 60em; margin: auto; }
+ .title { text-align: center;
+ margin-bottom: .2em; }
+ .subtitle { text-align: center;
+ font-size: medium;
+ font-weight: bold;
+ margin-top:0; }
+ .todo { font-family: monospace; color: red; }
+ .done { font-family: monospace; color: green; }
+ .priority { font-family: monospace; color: orange; }
+ .tag { background-color: #eee; font-family: monospace;
+ padding: 2px; font-size: 80%; font-weight: normal; }
+ .timestamp { color: #bebebe; }
+ .timestamp-kwd { color: #5f9ea0; }
+ .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
+ .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
+ .org-center { margin-left: auto; margin-right: auto; text-align: center; }
+ .underline { text-decoration: underline; }
+ #postamble p, #preamble p { font-size: 90%; margin: .2em; }
+ p.verse { margin-left: 3%; }
+ pre {
+ border: 1px solid #e6e6e6;
+ border-radius: 3px;
+ background-color: #f2f2f2;
+ padding: 8pt;
+ font-family: monospace;
+ overflow: auto;
+ margin: 1.2em;
+ }
+ pre.src {
+ position: relative;
+ overflow: auto;
+ }
+ pre.src:before {
+ display: none;
+ position: absolute;
+ top: -8px;
+ right: 12px;
+ padding: 3px;
+ color: #555;
+ background-color: #f2f2f299;
+ }
+ pre.src:hover:before { display: inline; margin-top: 14px;}
+ /* Languages per Org manual */
+ pre.src-asymptote:before { content: 'Asymptote'; }
+ pre.src-awk:before { content: 'Awk'; }
+ pre.src-authinfo::before { content: 'Authinfo'; }
+ pre.src-C:before { content: 'C'; }
+ /* pre.src-C++ doesn't work in CSS */
+ pre.src-clojure:before { content: 'Clojure'; }
+ pre.src-css:before { content: 'CSS'; }
+ pre.src-D:before { content: 'D'; }
+ pre.src-ditaa:before { content: 'ditaa'; }
+ pre.src-dot:before { content: 'Graphviz'; }
+ pre.src-calc:before { content: 'Emacs Calc'; }
+ pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
+ pre.src-fortran:before { content: 'Fortran'; }
+ pre.src-gnuplot:before { content: 'gnuplot'; }
+ pre.src-haskell:before { content: 'Haskell'; }
+ pre.src-hledger:before { content: 'hledger'; }
+ pre.src-java:before { content: 'Java'; }
+ pre.src-js:before { content: 'Javascript'; }
+ pre.src-latex:before { content: 'LaTeX'; }
+ pre.src-ledger:before { content: 'Ledger'; }
+ pre.src-lisp:before { content: 'Lisp'; }
+ pre.src-lilypond:before { content: 'Lilypond'; }
+ pre.src-lua:before { content: 'Lua'; }
+ pre.src-matlab:before { content: 'MATLAB'; }
+ pre.src-mscgen:before { content: 'Mscgen'; }
+ pre.src-ocaml:before { content: 'Objective Caml'; }
+ pre.src-octave:before { content: 'Octave'; }
+ pre.src-org:before { content: 'Org mode'; }
+ pre.src-oz:before { content: 'OZ'; }
+ pre.src-plantuml:before { content: 'Plantuml'; }
+ pre.src-processing:before { content: 'Processing.js'; }
+ pre.src-python:before { content: 'Python'; }
+ pre.src-R:before { content: 'R'; }
+ pre.src-ruby:before { content: 'Ruby'; }
+ pre.src-sass:before { content: 'Sass'; }
+ pre.src-scheme:before { content: 'Scheme'; }
+ pre.src-screen:before { content: 'Gnu Screen'; }
+ pre.src-sed:before { content: 'Sed'; }
+ pre.src-sh:before { content: 'shell'; }
+ pre.src-sql:before { content: 'SQL'; }
+ pre.src-sqlite:before { content: 'SQLite'; }
+ /* additional languages in org.el's org-babel-load-languages alist */
+ pre.src-forth:before { content: 'Forth'; }
+ pre.src-io:before { content: 'IO'; }
+ pre.src-J:before { content: 'J'; }
+ pre.src-makefile:before { content: 'Makefile'; }
+ pre.src-maxima:before { content: 'Maxima'; }
+ pre.src-perl:before { content: 'Perl'; }
+ pre.src-picolisp:before { content: 'Pico Lisp'; }
+ pre.src-scala:before { content: 'Scala'; }
+ pre.src-shell:before { content: 'Shell Script'; }
+ pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
+ /* additional language identifiers per "defun org-babel-execute"
+ in ob-*.el */
+ pre.src-cpp:before { content: 'C++'; }
+ pre.src-abc:before { content: 'ABC'; }
+ pre.src-coq:before { content: 'Coq'; }
+ pre.src-groovy:before { content: 'Groovy'; }
+ /* additional language identifiers from org-babel-shell-names in
+ ob-shell.el: ob-shell is the only babel language using a lambda to put
+ the execution function name together. */
+ pre.src-bash:before { content: 'bash'; }
+ pre.src-csh:before { content: 'csh'; }
+ pre.src-ash:before { content: 'ash'; }
+ pre.src-dash:before { content: 'dash'; }
+ pre.src-ksh:before { content: 'ksh'; }
+ pre.src-mksh:before { content: 'mksh'; }
+ pre.src-posh:before { content: 'posh'; }
+ /* Additional Emacs modes also supported by the LaTeX listings package */
+ pre.src-ada:before { content: 'Ada'; }
+ pre.src-asm:before { content: 'Assembler'; }
+ pre.src-caml:before { content: 'Caml'; }
+ pre.src-delphi:before { content: 'Delphi'; }
+ pre.src-html:before { content: 'HTML'; }
+ pre.src-idl:before { content: 'IDL'; }
+ pre.src-mercury:before { content: 'Mercury'; }
+ pre.src-metapost:before { content: 'MetaPost'; }
+ pre.src-modula-2:before { content: 'Modula-2'; }
+ pre.src-pascal:before { content: 'Pascal'; }
+ pre.src-ps:before { content: 'PostScript'; }
+ pre.src-prolog:before { content: 'Prolog'; }
+ pre.src-simula:before { content: 'Simula'; }
+ pre.src-tcl:before { content: 'tcl'; }
+ pre.src-tex:before { content: 'TeX'; }
+ pre.src-plain-tex:before { content: 'Plain TeX'; }
+ pre.src-verilog:before { content: 'Verilog'; }
+ pre.src-vhdl:before { content: 'VHDL'; }
+ pre.src-xml:before { content: 'XML'; }
+ pre.src-nxml:before { content: 'XML'; }
+ /* add a generic configuration mode; LaTeX export needs an additional
+ (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
+ pre.src-conf:before { content: 'Configuration File'; }
+
+ table { border-collapse:collapse; }
+ caption.t-above { caption-side: top; }
+ caption.t-bottom { caption-side: bottom; }
+ td, th { vertical-align:top; }
+ th.org-right { text-align: center; }
+ th.org-left { text-align: center; }
+ th.org-center { text-align: center; }
+ td.org-right { text-align: right; }
+ td.org-left { text-align: left; }
+ td.org-center { text-align: center; }
+ dt { font-weight: bold; }
+ .footpara { display: inline; }
+ .footdef { margin-bottom: 1em; }
+ .figure { padding: 1em; }
+ .figure p { text-align: center; }
+ .equation-container {
+ display: table;
+ text-align: center;
+ width: 100%;
+ }
+ .equation {
+ vertical-align: middle;
+ }
+ .equation-label {
+ display: table-cell;
+ text-align: right;
+ vertical-align: middle;
+ }
+ .inlinetask {
+ padding: 10px;
+ border: 2px solid gray;
+ margin: 10px;
+ background: #ffffcc;
+ }
+ #org-div-home-and-up
+ { text-align: right; font-size: 70%; white-space: nowrap; }
+ textarea { overflow-x: auto; }
+ .linenr { font-size: smaller }
+ .code-highlighted { background-color: #ffff00; }
+ .org-info-js_info-navigation { border-style: none; }
+ #org-info-js_console-label
+ { font-size: 10px; font-weight: bold; white-space: nowrap; }
+ .org-info-js_search-highlight
+ { background-color: #ffff00; color: #000000; font-weight: bold; }
+ .org-svg { }
+</style>
+</head>
+<body>
+<div id="content" class="content">
+<h1 class="title">Chotto</h1>
+<div id="table-of-contents" role="doc-toc">
+<h2>Table of Contents</h2>
+<div id="text-table-of-contents" role="doc-toc">
+<ul>
+<li><a href="#org0d48161">1. Naming &amp; Afew</a></li>
+<li><a href="#org0154d9d">2. Prerequisites</a></li>
+<li><a href="#org8d840c5">3. Configuration</a></li>
+<li><a href="#org4259fc2">4. Config</a></li>
+<li><a href="#orgb9835ee">5. Rule sets</a></li>
+</ul>
+</div>
+</div>
+<p>
+Chotto is an initial tagging script for Notmuch
+</p>
+<ul class="org-ul">
+<li><a href="http://notmuchmail.org/">http://notmuchmail.org/</a></li>
+<li><a href="http://notmuchmail.org/initial_tagging/">http://notmuchmail.org/initial_tagging/</a></li>
+</ul>
+
+<p>
+Chotto is written in Ruby and had a (quite) nice DSL for configuration.
+</p>
+
+<div id="outline-container-org0d48161" class="outline-2">
+<h2 id="org0d48161"><span class="section-number-2">1.</span> Naming &amp; Afew</h2>
+<div class="outline-text-2" id="text-1">
+<p>
+Notmuch ecosystem already has a great script for initial tagging - afew.
+However it is written in Python and therefore it's always a gamble if it will consider the user worthy or running.
+</p>
+
+<p>
+Chotto, <code>a few</code> in Japanese.
+Because afew refused to work on my system.
+And because I love Ruby!
+</p>
+</div>
+</div>
+
+<div id="outline-container-org0154d9d" class="outline-2">
+<h2 id="org0154d9d"><span class="section-number-2">2.</span> Prerequisites</h2>
+<div class="outline-text-2" id="text-2">
+<p>
+Chotto expects:
+</p>
+<ul class="org-ul">
+<li>ruby 3x</li>
+<li>notmuch</li>
+<li>notmuch ruby bindings.</li>
+</ul>
+
+<p>
+While the first 2 are obvious, getting ruby bindings to work may be an adventure on its own.
+</p>
+
+<p>
+<b>FreeBSD</b> provides a ready package <code>ruby-notmuch</code>.
+</p>
+
+<p>
+<b>MacOS</b> requires compiling from source, which will be problematic due to linking difficulties.
+It's not an OS designed for technical folks.
+</p>
+
+<p>
+Some <b>Linux</b> distros provide the bindings in their package managers, but otherwise compiling should be easy.
+</p>
+
+<p>
+If you use <b>Windows</b>, you have my sympathy.
+</p>
+</div>
+</div>
+
+<div id="outline-container-org8d840c5" class="outline-2">
+<h2 id="org8d840c5"><span class="section-number-2">3.</span> Configuration</h2>
+<div class="outline-text-2" id="text-3">
+<p>
+Chotto expects the configuration file to be present in
+</p>
+
+<p>
+<code>~/.config/chotto/config.rb</code>
+</p>
+
+<p>
+The user needs to add (at least) two blocks to the file: config &amp; rule sets
+</p>
+</div>
+</div>
+
+<div id="outline-container-org4259fc2" class="outline-2">
+<h2 id="org4259fc2"><span class="section-number-2">4.</span> Config</h2>
+<div class="outline-text-2" id="text-4">
+<p>
+Presently, the only option Config expects is the absolute path to the Notmuch database:
+</p>
+
+<p>
+Chotto.configure do
+ config.database<sub>path</sub> = <code>/home/&lt;user&gt;/mail</code>
+end
+</p>
+
+<p>
+Please, adjust the path to the valid location
+</p>
+</div>
+</div>
+
+<div id="outline-container-orgb9835ee" class="outline-2">
+<h2 id="orgb9835ee"><span class="section-number-2">5.</span> Rule sets</h2>
+<div class="outline-text-2" id="text-5">
+<p>
+The actual magic happens in <code>Rule Sets</code> which are sets of filters &amp; tag modifications.
+A very simple rule set can look like:
+</p>
+
+<div class="org-src-container">
+<pre class="src src-ruby">Chotto.rule_set "notes" do
+ messages.filter(from: "&lt;my email&gt;").each do |msg|
+ msg.tags &lt;&lt; "note"
+ msg.save!
+ end
+end
+</pre>
+</div>
+
+<p>
+Let's break it down.
+</p>
+
+<p>
+First, we define a named <code>rule_set</code>.
+The name can be a string or a hash and is currently not used anywhere.
+It makes it easier to manager bigger rule sets.
+</p>
+
+<p>
+Then we search for messages.
+In this case, we want all messages sent from <code>&lt;my email&gt;</code> .
+</p>
+
+<p>
+After, we loop over each found message.
+</p>
+
+<p>
+msg.tags returns a mutable array, and we can mutate is as such.
+</p>
+
+<p>
+Lastly, we save! the message in the database.
+</p>
+
+<p>
+Filter language
+</p>
+<hr />
+
+<p>
+We can quite easily filter messages based. Chotto accepts filters as:
+</p>
+<ul class="org-ul">
+<li>Strings (from(<code>Subject:Hired!</code>)).
+The string will not be modified.</li>
+<li><p>
+Hash with string values (from(subject: <code>Hired</code>)).
+The key of each hash element is a modified header value - it's down cased, and <code>-</code> becomes <code>_</code>, therefore:
+</p>
+<ul class="org-ul">
+<li><code>X-Spam-Id</code> becomes <code>x_spam_id</code></li>
+<li><code>X-Thread-Id</code> becomes <code>x_thread_id</code></li>
+</ul>
+
+<p>
+The values on the other hand can be:
+</p>
+<ul class="org-ul">
+<li>String.
+Kind of obvious.</li>
+<li>Array.
+Arrays here are treated as the current conjunctions.
+The default conjunction here is <code>OR</code>, so <code>k: [1,2]</code> will become <code>key:1 OR key:2</code></li>
+</ul>
+
+<p>
+User can add multiple elements to the hash, and they will be join in the current conjunction mode.
+By default the mode is <code>AND</code>, therefore:
+</p>
+
+<p>
+{key: 'val1', key2: 'val2'} are treated as <code>key:val1 AND key2:val2</code>.
+</p>
+
+<p>
+<code>filter</code> returns self, therefore we can combine multiple filters <code>filter(key1: 'val').filter(key2: 'val2')</code>.
+Filters will be joined in the current conjunction mode.
+</p>
+
+<p>
+Conjunction mode can be changed using the <code>or</code> and <code>and</code> methods: filter(key1: <code>val1</code>).or.filter(key2: <code>val2</code>).
+</p>
+
+<p>
+The language is simple, but gives huge chances to go wrong.
+You can test what is produced by calling <code>#to_query_string</code> on messages instance.
+</p></li>
+</ul>
+</div>
+</div>
+</div>
+<div id="postamble" class="status">
+<p class="author">Author: User Mms</p>
+<p class="date">Created: 2024-11-12 Tue 23:12</p>
+<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
+</div>
+</body>
+</html>
diff --git a/README.md b/README.md
deleted file mode 100644
index ed201df..0000000
--- a/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# some
-
-An inititial tagger for Notmucn \ No newline at end of file
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..5a8b406
--- /dev/null
+++ b/README.org
@@ -0,0 +1,114 @@
+#+TITLE: Chotto
+#+VERSION: 0.0.1
+
+Chotto is an initial tagging script for Notmuch
+- http://notmuchmail.org/
+- http://notmuchmail.org/initial_tagging/
+
+Chotto is written in Ruby and had a (quite) nice DSL for configuration.
+
+* Naming & Afew
+Notmuch ecosystem already has a great script for initial tagging - afew.
+However it is written in Python and therefore it's always a gamble if it will consider the user worthy or running.
+
+Chotto, =a few= in Japanese.
+Because afew refused to work on my system.
+And because I love Ruby!
+
+* Prerequisites
+Chotto expects:
+- ruby 3x
+- notmuch
+- notmuch ruby bindings.
+
+While the first 2 are obvious, getting ruby bindings to work may be an adventure on its own.
+
+*FreeBSD* provides a ready package =ruby-notmuch=.
+
+*MacOS* requires compiling from source, which will be problematic due to linking difficulties.
+It's not an OS designed for technical folks.
+
+Some *Linux* distros provide the bindings in their package managers, but otherwise compiling should be easy.
+
+If you use *Windows*, you have my sympathy.
+
+* Configuration
+Chotto expects the configuration file to be present in
+
+=~/.config/chotto/config.rb=
+
+The user needs to add (at least) two blocks to the file: config & rule sets
+
+* Config
+Presently, the only option Config expects is the absolute path to the Notmuch database:
+
+Chotto.configure do
+ config.database_path = =/home/<user>/mail=
+end
+
+Please, adjust the path to the valid location
+
+* Rule sets
+The actual magic happens in =Rule Sets= which are sets of filters & tag modifications.
+A very simple rule set can look like:
+
+#+BEGIN_SRC ruby
+Chotto.rule_set "notes" do
+ messages.filter(from: "<my email>").each do |msg|
+ msg.tags << "note"
+ msg.save!
+ end
+end
+#+END_SRC
+
+Let's break it down.
+
+First, we define a named =rule_set=.
+The name can be a string or a hash and is currently not used anywhere.
+It makes it easier to manager bigger rule sets.
+
+Then we search for messages.
+In this case, we want all messages sent from =<my email>= .
+
+After, we loop over each found message.
+
+msg.tags returns a mutable array, and we can mutate is as such.
+
+Lastly, we save! the message in the database.
+
+Filter language
+------------------------------------------
+
+We can quite easily filter messages based. Chotto accepts filters as:
+- Strings (from(=Subject:Hired!=)).
+ The string will not be modified.
+- Hash with string values (from(subject: =Hired=)).
+ The key of each hash element is a modified header value - it's down cased, and =-= becomes =_=, therefore:
+ - =X-Spam-Id= becomes =x_spam_id=
+ - =X-Thread-Id= becomes =x_thread_id=
+
+ The values on the other hand can be:
+ - String.
+ Kind of obvious.
+ - Array.
+ Arrays here are treated as the current conjunctions.
+ The default conjunction here is =OR=, so =k: [1,2]= will become =key:1 OR key:2=
+
+ User can add multiple elements to the hash, and they will be join in the current conjunction mode.
+ By default the mode is =AND=, therefore:
+
+ {key: 'val1', key2: 'val2'} are treated as =key:val1 AND key2:val2=.
+
+ =filter= returns self, therefore we can combine multiple filters =filter(key1: 'val').filter(key2: 'val2')=.
+ Filters will be joined in the current conjunction mode.
+
+ Conjunction mode can be changed using the =or= and =and= methods: filter(key1: =val1=).or.filter(key2: =val2=).
+
+ The language is simple, but gives huge chances to go wrong.
+ You can test what is produced by calling =#to_query_string= on messages instance.
+
+
+
+
+
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..aabe8a7
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,143 @@
+ __________
+
+ CHOTTO
+
+ User Mms
+ __________
+
+
+Table of Contents
+_________________
+
+1. Naming & Afew
+2. Prerequisites
+3. Configuration
+4. Config
+5. Rule sets
+
+
+Chotto is an initial tagging script for Notmuch
+- <http://notmuchmail.org/>
+- <http://notmuchmail.org/initial_tagging/>
+
+Chotto is written in Ruby and had a (quite) nice DSL for configuration.
+
+
+1 Naming & Afew
+===============
+
+ Notmuch ecosystem already has a great script for initial tagging -
+ afew. However it is written in Python and therefore it's always a
+ gamble if it will consider the user worthy or running.
+
+ Chotto, `a few' in Japanese. Because afew refused to work on my
+ system. And because I love Ruby!
+
+
+2 Prerequisites
+===============
+
+ Chotto expects:
+ - ruby 3x
+ - notmuch
+ - notmuch ruby bindings.
+
+ While the first 2 are obvious, getting ruby bindings to work may be an
+ adventure on its own.
+
+ *FreeBSD* provides a ready package `ruby-notmuch'.
+
+ *MacOS* requires compiling from source, which will be problematic due
+ to linking difficulties. It's not an OS designed for technical folks.
+
+ Some *Linux* distros provide the bindings in their package managers,
+ but otherwise compiling should be easy.
+
+ If you use *Windows*, you have my sympathy.
+
+
+3 Configuration
+===============
+
+ Chotto expects the configuration file to be present in
+
+ `~/.config/chotto/config.rb'
+
+ The user needs to add (at least) two blocks to the file: config & rule
+ sets
+
+
+4 Config
+========
+
+ Presently, the only option Config expects is the absolute path to the
+ Notmuch database:
+
+ Chotto.configure do config.database_path = `/home/<user>/mail' end
+
+ Please, adjust the path to the valid location
+
+
+5 Rule sets
+===========
+
+ The actual magic happens in `Rule Sets' which are sets of filters &
+ tag modifications. A very simple rule set can look like:
+
+ ,----
+ | Chotto.rule_set "notes" do
+ | messages.filter(from: "<my email>").each do |msg|
+ | msg.tags << "note"
+ | msg.save!
+ | end
+ | end
+ `----
+
+ Let's break it down.
+
+ First, we define a named `rule_set'. The name can be a string or a
+ hash and is currently not used anywhere. It makes it easier to
+ manager bigger rule sets.
+
+ Then we search for messages. In this case, we want all messages sent
+ from `<my email>' .
+
+ After, we loop over each found message.
+
+ msg.tags returns a mutable array, and we can mutate is as such.
+
+ Lastly, we save! the message in the database.
+
+ Filter language
+ ----------------------------------------------------------------------
+
+ We can quite easily filter messages based. Chotto accepts filters as:
+ - Strings (from(`Subject:Hired!')). The string will not be modified.
+ - Hash with string values (from(subject: `Hired')). The key of each
+ hash element is a modified header value - it's down cased, and `-'
+ becomes `_', therefore:
+ - `X-Spam-Id' becomes `x_spam_id'
+ - `X-Thread-Id' becomes `x_thread_id'
+
+ The values on the other hand can be:
+ - String. Kind of obvious.
+ - Array. Arrays here are treated as the current conjunctions. The
+ default conjunction here is `OR', so `k: [1,2]' will become `key:1
+ OR key:2'
+
+ User can add multiple elements to the hash, and they will be join in
+ the current conjunction mode. By default the mode is `AND',
+ therefore:
+
+ {key: 'val1', key2: 'val2'} are treated as `key:val1 AND key2:val2'.
+
+ `filter' returns self, therefore we can combine multiple filters
+ `filter(key1: 'val').filter(key2: 'val2')'. Filters will be joined
+ in the current conjunction mode.
+
+ Conjunction mode can be changed using the `or' and `and' methods:
+ filter(key1: `val1').or.filter(key2: `val2').
+
+ The language is simple, but gives huge chances to go wrong. You can
+ test what is produced by calling `#to_query_string' on messages
+ instance.
diff --git a/lib/osugiru.rb b/lib/osugiru.rb
index 91a2c06..4e99212 100644
--- a/lib/osugiru.rb
+++ b/lib/osugiru.rb
@@ -3,12 +3,13 @@
require 'notmuch'
require 'pry'
-require_relative 'osugiru/database'
require_relative 'osugiru/config'
+require_relative 'osugiru/database'
+require_relative 'osugiru/helpers'
require_relative 'osugiru/message'
require_relative 'osugiru/messages'
-require_relative 'osugiru/helpers'
require_relative 'osugiru/ruleset'
+require_relative 'osugiru/tags'
module Osugiru
class << self
diff --git a/lib/osugiru/database.rb b/lib/osugiru/database.rb
index d014c94..0d33a24 100644
--- a/lib/osugiru/database.rb
+++ b/lib/osugiru/database.rb
@@ -5,7 +5,7 @@ module Osugiru
attr_reader :db
def initialize(path:)
- @db = ::Notmuch::Database.new(path)
+ @db = ::Notmuch::Database.new(path, mode: Notmuch::MODE_READ_WRITE)
end
def query(query)
diff --git a/lib/osugiru/message.rb b/lib/osugiru/message.rb
index 3446f17..0555724 100644
--- a/lib/osugiru/message.rb
+++ b/lib/osugiru/message.rb
@@ -6,9 +6,10 @@ module Osugiru
def initialize(msg:)
@message = msg
+ @tags = @message.tags
end
- def method_missing(method_name, *_args)
+ def method_missing(method_name, *_args)
handle_get(Osugiru::Helpers.header_name_from_dsl(method_name))
end
@@ -17,7 +18,19 @@ module Osugiru
end
def tags
- @message.tags
+ @tags
+ end
+
+ def tags=(new_tags)
+ @tags = new_tags
+ end
+
+ def save!
+ message.remove_all_tags
+ tags.each do |tag|
+ message.add_tag(tag)
+ end
+ binding.pry
end
end
end