Skip to content

Commit 524ed29

Browse files
authored
Merge branch 'main' into refactor-tilde-expansion
2 parents 8d0e552 + 0787930 commit 524ed29

File tree

14 files changed

+60
-3
lines changed

14 files changed

+60
-3
lines changed

docs/editors-integration.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ This LSP command calls `zk list` to search a notebook. It takes two arguments:
202202
2. <details><summary>A dictionary of additional options (click to expand)</summary>
203203

204204
| Key | Type | Required? | Description |
205-
| ------------------ | -------------- | ----------- | ------------------------------------------------------------------------- |
205+
| ------------------ | -------------- | ----------- | --------------------------------------------------------------------------------------------------------- |
206206
| `select` | string array | Yes | List of note fields to return<sup>1</sup> |
207207
| `hrefs` | string array | No | Find notes matching the given path, including its descendants |
208208
| `limit` | integer | No | Limit the number of notes found |
@@ -216,6 +216,7 @@ This LSP command calls `zk list` to search a notebook. It takes two arguments:
216216
| `linkTo` | string array | No | Find notes which are linking to the given ones |
217217
| `linkedBy` | string array | No | Find notes which are linked by the given ones |
218218
| `orphan` | boolean | No | Find notes which are not linked by any other note |
219+
| `tagless` | boolean | No | Find notes which have no tags |
219220
| `related` | string array | No | Find notes which might be related to the given ones |
220221
| `maxDistance` | integer | No | Maximum distance between two linked notes |
221222
| `recursive` | boolean | No | Follow links recursively |
@@ -242,7 +243,7 @@ This LSP command calls `zk tag list` to return the list of tags in a notebook. I
242243

243244
| Key | Type | Required? | Description |
244245
|--------|--------------|-----------|--------------------------------------------------|
245-
| `sort` | string array | No | Order the tags by the given criteria<sup>1</sup> |
246+
| `sort` | string array | No | Order the tags by the given criteria<sup>1</sup> |
246247

247248
1. The available sort criteria are `name` and `note-count`. You can change the order by appending `-` or `+` to the criterion.
248249

docs/note-filtering.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,18 @@ $ zk list --tag "NOT done"
190190

191191
Your shell might give you some trouble using the `-` prefix. You can quote it and add an extra space as a workaround, e.g. `--tag " -done"`.
192192

193-
Finally, you can use glob patterns to match multiple tags. This is particularly useful if you use a separator (e.g. `/`) to group multiple tags under a parent tag.
193+
You can use glob patterns to match multiple tags. This is particularly useful if you use a separator (e.g. `/`) to group multiple tags under a parent tag.
194194

195195
```sh
196196
$ zk list --tag "year/201*"
197197
```
198198

199+
A useful [notebook housekeeping](notebook-housekeeping.md) feature is to find tags which _do not_ have tags.
200+
201+
```sh
202+
$ zk list --tagless
203+
```
204+
199205
## Filter by creation or modification date
200206

201207
To find notes created or modified on a specific day, use `--created <date>` and `--modified <date>`. They accept a human-friendly date for argument.

docs/notebook-housekeeping.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ $ zk list --format '{{word-count}}\t{{title}}' --sort word-count --limit 20
2424
86 Anatomy of a notebook
2525
...
2626
```
27+
28+
## Find notes without tags
29+
30+
```sh
31+
$ zk list --tagless
32+
```

internal/adapter/sqlite/note_dao.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,10 @@ WHERE collection_id IN (SELECT id FROM collections t WHERE kind = '%s' AND (%s))
653653
)`)
654654
}
655655

656+
if opts.Tagless {
657+
whereExprs = append(whereExprs, `tags IS NULL`)
658+
}
659+
656660
if opts.CreatedStart != nil {
657661
whereExprs = append(whereExprs, "created >= ?")
658662
args = append(args, opts.CreatedStart)

internal/cli/filtering.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Filtering struct {
2929
LinkedBy []string `kong:"group='filter',short='L',placeholder='PATH',help='Find notes which are linked by the given ones.'" json:"linkedBy"`
3030
NoLinkedBy []string `kong:"group='filter',placeholder='PATH',help='Find notes which are not linked by the given ones.'" json:"-"`
3131
Orphan bool `kong:"group='filter',help='Find notes which are not linked by any other note.'" json:"orphan"`
32+
Tagless bool `kong:"group='filter',help='Find notes which have no tags.'" json:"tagless"`
3233
Related []string `kong:"group='filter',placeholder='PATH',help='Find notes which might be related to the given ones.'" json:"related"`
3334
MaxDistance int `kong:"group='filter',placeholder='COUNT',help='Maximum distance between two linked notes.'" json:"maxDistance"`
3435
Recursive bool `kong:"group='filter',short='r',help='Follow links recursively.'" json:"recursive"`
@@ -89,6 +90,7 @@ func (f Filtering) ExpandNamedFilters(filters map[string]string, expandedFilters
8990
f.ExactMatch = f.ExactMatch || parsedFilter.ExactMatch
9091
f.Interactive = f.Interactive || parsedFilter.Interactive
9192
f.Orphan = f.Orphan || parsedFilter.Orphan
93+
f.Tagless = f.Tagless || parsedFilter.Tagless
9294
f.Recursive = f.Recursive || parsedFilter.Recursive
9395

9496
if f.Limit == 0 {
@@ -203,6 +205,7 @@ func (f Filtering) NewNoteFindOpts(notebook *core.Notebook) (core.NoteFindOpts,
203205
}
204206

205207
opts.Orphan = f.Orphan
208+
opts.Tagless = f.Tagless
206209

207210
if f.Created != "" {
208211
start, end, err := parseDayRange(f.Created)

internal/core/note_find.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type NoteFindOpts struct {
3838
Related []string
3939
// Filter to select notes having no other notes linking to them.
4040
Orphan bool
41+
// Filter to select notes having no tags.
42+
Tagless bool
4143
// Filter notes created after the given date.
4244
CreatedStart *time.Time
4345
// Filter notes created before the given date.

tests/cmd-graph.tesh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ $ zk graph --help
4343
> ones.
4444
> --orphan Find notes which are not linked by any other
4545
> note.
46+
> --tagless Find notes which have no tags.
4647
> --related=PATH,... Find notes which might be related to the
4748
> given ones.
4849
> --max-distance=COUNT Maximum distance between two linked notes.

tests/cmd-list.tesh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ $ zk list --help
5151
> ones.
5252
> --orphan Find notes which are not linked by any other
5353
> note.
54+
> --tagless Find notes which have no tags.
5455
> --related=PATH,... Find notes which might be related to the
5556
> given ones.
5657
> --max-distance=COUNT Maximum distance between two linked notes.

tests/fixtures/tagless/.zk/config.toml

Whitespace-only changes.

tests/fixtures/tagless/inline.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: This note has inline tags
3+
date: 2024-08-22
4+
---
5+
6+
This #note has #inline tags.

0 commit comments

Comments
 (0)