From 850907ed9a68a46aad0a6d6c7ffdd8769e68e7e9 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 30 Sep 2022 16:48:59 -0400 Subject: [PATCH] fix(lib): doom/delete-this-file nil path handling Fix the handling of a nil path within doom/delete-this-file. If path is nil (e.g. called interactively when buffer is not visiting a file), avoid calling abbreviate-file-name on nil, otherwise an error will be signaled: (wrong-type-argument stringp nil) Additionally, fix the subsequent path checks. These were treating two distinct scenarios as a "Buffer is not visiting any file" user-error: - nil path - non-existent path - Only the first should result in that error. The second should proceed to the next path check (which was previously unreachable), to signal the appropriate error, "File doesn't exist: %s". --- lisp/lib/files.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 263b66082..7a5429c62 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -405,8 +405,8 @@ If FORCE-P, delete without confirmation." (list (buffer-file-name (buffer-base-buffer)) current-prefix-arg)) (let* ((path (or path (buffer-file-name (buffer-base-buffer)))) - (short-path (abbreviate-file-name path))) - (unless (and path (file-exists-p path)) + (short-path (and path (abbreviate-file-name path)))) + (unless path (user-error "Buffer is not visiting any file")) (unless (file-exists-p path) (error "File doesn't exist: %s" path))