如何通过elisp创建一个空文件? [英] How to create an empty file by elisp?

查看:114
本文介绍了如何通过elisp创建一个空文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个通过UI创建的定制的显式文件。它被命名为 custom.el 。目前,如果不存在,我使用跟随的片段来创建此文件。

I set an explicit file to customization created via the UI. It's named custom.el. Currently, I use the followed snippets to create this file if not exist.

(defconst custom-file (expand-file-name "custom.el" user-emacs-directory))
(unless (file-exists-p custom-file)
  (shell-command (concat "touch " custom-file)))

有一个丑陋的shell命令 touch in,any其他elisp函数可以这样做?

There is an ugly shell-command touch in, any other elisp functions can do this?

推荐答案

您可以使用(write-regionnil custom-文件)不确定是理想的解决方案。

You can use (write-region "" nil custom-file) not sure that is the ideal solution.

这篇关于如何通过elisp创建一个空文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆