ox-hugo icon indicating copy to clipboard operation
ox-hugo copied to clipboard

fix: properly escape dot in directory-files regex, fixes false matches

Open valer-cara opened this issue 1 year ago • 3 comments

It appears that the original regex took \. as a single dot (any character) rather than a literal dot.

I assume it's because single backslashes are dropped in emacs strings if the character following needs no escape as part of a string. However that's desired in the regex.

See https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-for-Strings.html


In my case, it matched a ./beorg subdir causing a further error during the export process -- not a regular file.

valer-cara avatar Oct 13 '23 16:10 valer-cara

I misidentified the issue I had. Turns out it was coming from a misconfigured value for org-agenda-text-search-extra-files which included an empty string in the list, causing the returned file list to also include the current directory. I'll close this PR, apologies for the noise here :raised_hands:

valer-cara avatar Oct 16 '23 12:10 valer-cara

No worries! I'm glad you sorted it out.

kaushalmodi avatar Oct 16 '23 12:10 kaushalmodi

I just switched to a new computer where I had not mangled the ox-hugo.el code. It had the same issue.

It can be tested by adding a non-regular file, eg. a dir ending in "org" in the current directory of the file to be exported. The code below should reproduce the problem, ran in the buffer to be exported.

(make-directory "foo-org")
(org-hugo-export-wim-to-md)

This should error with "not a regular file .../foo-org". I guess the changes in this PR are ok after all.

valer-cara avatar Oct 17 '23 12:10 valer-cara