Start a new topic

How do I create a filter for tags?

Here's what I've been using when trying to create a filter for tags: 


(filter-add "Project" (lambda (item) (string=? (item-tags item) "project")))

 I'm not the best at scheme - but I feel like I'm doing something wrong here? The tag shows up in the list but it doesn't work. Could it be that item-tags returns a list? Should I be using memq "project" to search through the list? 

Thanks for your work on the app by the way! This app is amazing and everything I could have asked for (and more) in an iPhone app for org files.

Yes, item-tags returns a list. So use member to check whether a tag is attached to an item.

For a quicker way to test filters you can type them straight into the search field without the lambda, e.g.

(string=? (item-state item) "TODO")

1 person likes this

 Awesome, thanks! I tried out the following:

(memq 'home (item-tags item)) 

 in the repl and I got the following:

Error: execute: unbound symbol: "item" []

 What would be the correct way to use it?

Before I was also trying:

(filter-add "Home" (lambda (item) (memq '@home (item-tags item)) ))

 And that wasn't working (This is for the tag @home). Honestly, I think I need to brush up on my scheme.

The 'home refers to a Scheme symbol rather than a string. You should find that...

(member "home" (item-tags item)) when entered in the search text field - or if defining a saved search manually in Scheme

(filter-add "Home" (lambda (item) (member "@home" (item-tags item))))
Login or Signup to post a comment