From 80ef677987558d2081c7b513d45c7f11d1d13b40 Mon Sep 17 00:00:00 2001 From: Alexander Grafov Date: Fri, 16 Dec 2016 13:22:59 +0300 Subject: [PATCH] Fix the bug with allowing remove any files (issue #6). Now only snippets those placed under default snippets dir allowed for deletion. --- go-playground.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/go-playground.el b/go-playground.el index f928d7c..b989890 100644 --- a/go-playground.el +++ b/go-playground.el @@ -134,8 +134,11 @@ func main() { "Remove files of the current snippet together with directory of this snippet." (interactive) (save-buffer) - (delete-directory (file-name-directory (buffer-file-name)) t t) - (kill-buffer)) + (if (string-match-p (file-truename go-playground-basedir) (file-truename (buffer-file-name))) + (progn (delete-directory (file-name-directory (buffer-file-name)) t t) + (kill-buffer)) + (message "Won't delete this! Because %s is not under the path %s. Remove the snippet manually!" + (buffer-file-name) go-playground-basedir))) ;;;###autoload (defun go-playground-remove-current-snippet ()