How to delete files with exclamation marks! using emacs' delete

I'm trying to make emacs' delete-file function delete files with exclamation marks in their names.

The particular use case is that I have set emacs to save all backup files in a single directory and to delete old backup files. However, when all backup files are placed in one directory, the directory separator / is replaced with ! .

When delete-file is called on a file with an exclamation mark in its name, it returns zero and the file is not deleted. It doesn't signal any error. Normally, delete-file returns nil. Anyway, emacs' backup system uses delete-file for deletion, and I'd rather not redefine the entire function just to change a single line.

I've tried backslashing the exclamation marks and shell-quoting the filename string, and neither has worked. I found out that something in my config is causing this, but I haven't figured out what yet. I have tracked the source of the problem to my custom system-move-file-to-trash function, which I now have to debug.

So, how can I make this work?

Emacs version: GNU Emacs 23.1.50.1
emacs-snapshot: Installed: 1:20090730-1~jaunty1


M-x delete-file

Then just enter the name of the file, don't escape anything, just the name,

!home!blah!filename

and it just works. And the same goes for the lisp invocation,

(delete-file "!home!blah!filename")

I found the answer. My custom system-move-file-to-trash function, which delete-file will automatically use, inappropriately called shell-quote-argument on the file name. Apparently arguments to a command run using call-process do not need to be shell-quoted.

链接地址: http://www.djcxy.com/p/38548.html

上一篇: 我如何隐藏emacs创建的备份文件?

下一篇: 如何删除带有感叹号的文件! 使用emacs的删除