How can I check if a file exists using Emacs Lisp?

前端 未结 3 1846
萌比男神i
萌比男神i 2021-02-01 12:09

I would like emacs to mark files that are generated as read-only when they\'re opened. The part of the puzzle that I\'m missing is how to check if a file \"exists\". I current

相关标签:
3条回答
  • 2021-02-01 12:28

    try file-exists-p

    "Return t if file filename exists (whether or not you can read it.)"

    0 讨论(0)
  • 2021-02-01 12:35
    • Depending on what you need, you might want file-readable-p instead of file-exists-p.

    • Apropos will only get you so far. Icicles provides apropos completion and progressive completion which let you find help easily for command, function, variable, etc. names that match subparts in an arbitrary order (is it file-exists-p or exists-file-p?).

    0 讨论(0)
  • 2021-02-01 12:42

    Use f.el, modern library for file and directory manipulation. You can use f-exists?, f-file?, f-directory? and many other predicates. The library is better than standard functions, because it's every file related function you'll ever need under one namespace.

    0 讨论(0)
提交回复
热议问题