我对以下代码有一点问题(它应该删除文件并终止缓冲区):
(defun bk-deletes-file ()
"Closes the buffer and deletes associated file."
(interactive)
(let (curFile curBuffer)
(if (file-exists-p buffer-file-name)
(progn
(setq curFile buffer-file-name)
(delete-file buffer-file-name))
(setq curFile 1))
(setq curBuffer (buffer-name))
(kill-this-buffer)
(if (stringp curFile)
(message "I've deleted %s and buried its buffer %s"
(file-name-nondirectory curFile) curBuffer)
(message "I've buried %s buffer" curBuffer)
)))
它不起作用:当我对没有文件的缓冲区进行操作时,它给出“如果:错误的类型参数:stringp,nil”,当我对文件的缓冲区进行操作时,它的行为就好像它是缓冲区-没有文件(即它打印“我已经掩埋了 %s 缓冲区” - 而它应该打印“我已经删除了 %s 并掩埋了它的缓冲区 %s”)