开发者

(directory-files) returns nil unexpectedly

开发者 https://www.devze.com 2023-03-31 22:50 出处:网络
The directory I keep my important files is stored as a string \"/home/wdkrnls/Org/\" in the variable org-dir.

The directory I keep my important files is stored as a string "/home/wdkrnls/Org/" in the variable org-dir.

I want to li开发者_C百科st all the files in org-dir that aren't backup files or org files (ie. that match ^[a-z0-9]+\.org$). So I typed the following into *Scratch*:

;; (directory-files DIRECTORY &optional FULL MATCH NOSORT)    
(directory-files    org-dir             '()  "^[a-z0-9]+\.org$")

But this returns nil. Even though ls in /eshell/ gives me:

Notes.org  Store  Tasks.org

Can you explain why mine doesn't work?


The problem is your regexp, you want:

"^[a-zA-Z0-9]+\\.org$"

You forgot the capitalized version of A-Z. And, you want a double \ so that the string reading leaves a \ in place to make the regexp treat the . as a ..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号