darlal / obsidian-switcher-plus

Enhanced Quick Switcher plugin for Obsidian.md
GNU General Public License v3.0
419 stars 11 forks source link

exclude attachments dir for all folders at all levels #165

Closed notuntoward closed 2 months ago

notuntoward commented 3 months ago

I have obsidian configured to create an attachments directory under every obsidian folder, and I also have it configured so that the file names of image attachments stored in the attachment directories start with the same name as the note .md file that links to them. So when I try to use switcher++ find a note file named "Price Normalization" I see this:

image

switcher++ does have a way to exclude directories via wildcards but I've got attachments directories everywhere in my vault, at varying nesting depths, making wildcards regexps giant and brittle.

I know that people do something similar with an "images" directories too.

So, would it be be possible to add a switcher++ option that would make it possible to exclude all directories of a certain name under every folder?

darlal commented 3 months ago

Hey @notuntoward perhaps I'm misunderstanding the issue you're running into, but it sounds like the Exclude folders setting should do exactly what you're looking for. So if you have a folder named attachments at varying depths in your folder structure and you want to exclude all of them no matter where they are found, you can just add attachments to the Exclude folders list. Please let me know if I've misunderstood what you're trying to do.

One other thing to note, the Exclude folders setting only applies to Heading List Mode which is unfortunately a misnomer, as it's not just for headings, it's really the mode that gives you all the extra features. In your screenshot, it looks like you're in Standard Mode, so Exclude folders won't apply in that mode.

notuntoward commented 3 months ago

Thanks for the response. As I understand it, the existing Exclude Folders options needs a path all the way from the vault root directory, but my attachments folders come and go frequently, sometimes without me even realizing it.

Maybe I have an unusual usage pattern, but I make and move folders frequently, and an attachments folder is made under them automatically. This is because, in Obsidian's "Files and Links" settings, I have:

So what I'm requesting is a way to exclude files under attachments wherever that folder happens to be.

darlal commented 3 months ago

Right, so as I mentioned above, just add the folder name attachments without any slashes (\, /) to the Exclude Folders list, and that will do what you want. A full path is only useful if you want to exclude specific folder paths, which is not what you're trying to do.

notuntoward commented 3 months ago

I tried that, but this didn't work, and it seems like what I'd expect, given the settings documentation:

image

Also, in the settings, I have "Search Headings" enabled.

darlal commented 2 months ago

it seems like what I'd expect, given the settings documentation

I wrote the documentation 🙂 also you can see what the code is actually doing here. I expect this to have no effect in Standard Mode because the setting is not evaluated in that case at all, but it should in Headings Mode.

I tried that, but this didn't work

It would be helpful if you could provide a bit more context around exactly what this means and the behavior you observed. Please provide:

  1. The exact steps that you took to try this out. Please include changes to settings, search term (all text/charaters in the switcher++ input text field), and the results displayed.
  2. An example of a specific folder path (not just a general pattern) that you'd expect to see excluded from the results after the settings changes. I understand you're looking for a general solution 🙂 this is just for testing purposes.
  3. Any errors reported in the obsidian console. To open the console, in Obsidian navigate to the View menu, then Toggle Developer Tools.

Thanks!

notuntoward commented 2 months ago

it seems like what I'd expect, given the settings documentation

I wrote the documentation 🙂 also you can see what the code is actually doing here.

The Settings documentation says "Path should start from Vault root," but you're saying that the path doesn't have to start from the Vault root. What I mean is that there appears to be a discrepancy between what code does, and what the documentation says it does.

I expect this to have no effect in Standard Mode because the setting is not evaluated in that case at all, but it should in Headings Mode.

Oh, now I get it: I must type # first before Exclude Folders setting takes effect -- I missed that when you mentioned it in your response.

I don't understand that design choice, but now I understand what to do.

Thanks for the explanation and the very useful plugin.

darlal commented 2 months ago

What I mean is that there appears to be a discrepancy between what code does, and what the documentation says it does.

The most common usecase for Exclude Folders is to ignore specific folder paths. The documentation tries to simplify and make that common usecase as easy/straighforward as possible. Clearly this simplification of the doc is at that expense of more advance usecases. I agree, there's definitely room to improve the doc and make it more comprehensive.

Oh, now I get it: I must type # first before Exclude Folders setting takes effect

Yep 🙂 # is the default trigger character (you can change it) for Headings Mode

I don't understand that design choice, but now I understand what to do.

The design choice is that Switcher++ is meant to be a drop-in replacement for the core out-of-the-box Obsidian Switcher, as such it supports all the standard core out-of-the-box Obsidian Switcher features in Standard Mode, and all the advanced features in Headings Mode (and others). Typing # triggers Switcher++ to operate in Headings Mode. Headings mode is really a misnomer, because it's really the "advanced", more powerful mode of operation - that's the mode when most of the extra/custom capabilities of Switcher++ are available for you to use. It's a separate "mode" to differentiate it from: first, the core Obsidian switcher functionality (Standard Mode), second, from the other custom modes/capabilities that switcher++ provides.

Thanks for the explanation and the very useful plugin.

Awesome, I'm glad you're finding it useful 🙂