about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/aerc-search.1.scd10
-rw-r--r--worker/notmuch/worker.go38
2 files changed, 39 insertions, 9 deletions
diff --git a/doc/aerc-search.1.scd b/doc/aerc-search.1.scd
index 58da44b..c86ed6a 100644
--- a/doc/aerc-search.1.scd
+++ b/doc/aerc-search.1.scd
@@ -9,3 +9,13 @@ aerc-search(1)
 	*-r*: Search for read messages
 
 	*-u*: Search for unread messages
+
+# NOTMUCH
+
+*search* <query...>
+	You can use the full notmuch query language as described in
+	*notmuch-search-terms*(7).
+
+	The query will only apply on top of the active folder query.
+
+	Example: jump to next unread `:search tag:unread`
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index d4c196c..58a63ec 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -90,12 +90,12 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error {
 		return w.handleFetchFullMessages(msg)
 	case *types.ReadMessages:
 		return w.handleReadMessages(msg)
-		// TODO
-		// 	return w.handleSearchDirectory(msg)
-		// case *types.DeleteMessages:
+	case *types.SearchDirectory:
+		return w.handleSearchDirectory(msg)
 
 		// not implemented, they are generally not used
 		// in a notmuch based workflow
+		// case *types.DeleteMessages:
 		// case *types.CopyMessages:
 		// 	return w.handleCopyMessages(msg)
 		// case *types.AppendMessage:
@@ -177,10 +177,10 @@ func (w *worker) handleListDirectories(msg *types.ListDirectories) error {
 	return nil
 }
 
-//query returns a query based on the query string on w.query.
-//it also configures the query as specified on the worker
-func (w *worker) getQuery() (*notmuch.Query, error) {
-	q := w.db.NewQuery(w.query)
+//getQuery returns a query based on the provided query string.
+//It also configures the query as specified on the worker
+func (w *worker) getQuery(query string) (*notmuch.Query, error) {
+	q := w.db.NewQuery(query)
 	q.SetExcludeScheme(notmuch.EXCLUDE_TRUE)
 	q.SetSortScheme(notmuch.SORT_OLDEST_FIRST)
 	for _, t := range w.excludedTags {
@@ -200,7 +200,7 @@ func (w *worker) handleOpenDirectory(msg *types.OpenDirectory) error {
 		q = msg.Directory
 	}
 	w.query = q
-	query, err := w.getQuery()
+	query, err := w.getQuery(w.query)
 	if err != nil {
 		return err
 	}
@@ -226,7 +226,7 @@ func (w *worker) handleOpenDirectory(msg *types.OpenDirectory) error {
 
 func (w *worker) handleFetchDirectoryContents(
 	msg *types.FetchDirectoryContents) error {
-	q, err := w.getQuery()
+	q, err := w.getQuery(w.query)
 	if err != nil {
 		return err
 	}
@@ -404,6 +404,26 @@ func (w *worker) handleReadMessages(msg *types.ReadMessages) error {
 	return nil
 }
 
+func (w *worker) handleSearchDirectory(msg *types.SearchDirectory) error {
+	// the first item is the command (search / filter)
+	s := strings.Join(msg.Argv[1:], " ")
+	// we only want to search in the current query, so merge the two together
+	search := fmt.Sprintf("(%v) and (%v)", w.query, s)
+	query, err := w.getQuery(search)
+	if err != nil {
+		return err
+	}
+	uids, err := w.uidsFromQuery(query)
+	if err != nil {
+		return err
+	}
+	w.w.PostMessage(&types.SearchResults{
+		Message: types.RespondTo(msg),
+		Uids:    uids,
+	}, nil)
+	return nil
+}
+
 func (w *worker) loadQueryMap(acctConfig *config.AccountConfig) error {
 	raw, ok := acctConfig.Params["query-map"]
 	if !ok {
1.9.0b1&id=1159f9ec182496ddc5324f23fb1d5eae73fe63e3'>1159f9ec ^
152823d8 ^
1c72dd08 ^


152823d8 ^

1c72dd08 ^

152823d8 ^

1c72dd08 ^


152823d8 ^









1159f9ec ^
1159f9ec ^


dd4a4145 ^
1159f9ec ^
dd4a4145 ^





1159f9ec ^
dd4a4145 ^


1159f9ec ^
dd4a4145 ^


1159f9ec ^
1159f9ec ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162