Skip to content

Issues on Windows due to case-sensitivity in various functions #109

@evanjs

Description

@evanjs

Problem

Initially, things seemed to work okay on Windows
I was able to install and configure into Doom Emacs
I could search my vault, use the results to directly open files, etc.

However, I tried to move a file to another location using obsidian-move-file
Emacs then told me that I was not viewing an Obsidian file

I tried vibe debugging it a bit using Anthropic's Claude, which came to this conclusion:

Windows is case-insensitive, but Emacs string comparison is case-sensitive by default.

It did provide me with a solution that appears to get a few more things working:

  • Vault indexing appears to scan files now (0 files found before)
  • File moving using the aforementioned obsidian-move-file appears to work as intended

Working Solution in my config

Here is what Claude came up with for my Doom config

  ;; Fix for Windows case sensitivity issue
  (defun obsidian-file-p (&optional file)
    "Return t if FILE is an obsidian.el file, nil otherwise. Fixed for Windows case sensitivity."
    (-when-let* ((raw-path (or file (buffer-file-name (buffer-base-buffer))))
                 (path (expand-file-name raw-path))
                 ;; Fix: Case-insensitive comparison on Windows
                 (vault-path (expand-file-name obsidian-directory))
                 (in-vault (if (eq system-type 'windows-nt)
                              (s-starts-with-p (downcase vault-path) (downcase path))
                            (s-starts-with-p vault-path path)))
                 (md-ext (s-ends-with-p ".md" path))
                 (not-dot-file (or obsidian-include-hidden-files
                                  (not (obsidian-dot-file-p path))))
                 (not-node-git-p (not (string-match-p (rx (or "node_modules" ".git")) path)))
                 (not-trash-p (obsidian-not-trash-p path))
                 (not-ignored-dir (obsidian-not-in-excluded-directory-p path))
                 (not-dot-obsidian (obsidian-not-dot-obsidian-p path)))
      t))

All that being said, I am a total elisp noob, but figured I should at least report the issue and my (or rather, Claude's) findings, what worked, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions