From b03b90fe0b18d125b6001c67b539017e88a830e2 Mon Sep 17 00:00:00 2001 From: Nathan Aclander Date: Tue, 9 May 2017 19:46:07 -0700 Subject: [PATCH] Add confirmation dialog of paste, before pasting --- webpaste.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/webpaste.el b/webpaste.el index fa7e5cf..2d303ed 100644 --- a/webpaste.el +++ b/webpaste.el @@ -68,6 +68,11 @@ default to all providers in order defined in ‘webpaste-providers’ list." :type '(alist :key-type symbol :value-type string) :group 'webpaste) +(defcustom webpaste/paste-confirmation nil + "Prompt for a yes/no confirmation before attempting to paste a region or +buffer" + :group 'webpaste) + (defvar webpaste/tested-providers () "Variable for storing which providers to try in which order while running. @@ -372,8 +377,11 @@ Argument POINT Current point. Argument MARK Current mark." (interactive "r") - ;; Extract the buffer contents with buffer-substring and paste it - (webpaste-paste-text (buffer-substring point mark))) + ;; unless we wanted a paste confirmation and declined + (unless (and webpaste/paste-confirmation + (not (yes-or-no-p "paste entire region?"))) + ;; Extract the buffer contents with buffer-substring and paste it + (webpaste-paste-text (buffer-substring point mark)))) ;;;###autoload @@ -381,8 +389,11 @@ Argument MARK Current mark." "Paste current buffer to some paste service." (interactive) - ;; Extract the buffer contents with buffer-substring and paste it - (webpaste-paste-text (buffer-substring (point-min) (point-max)))) + ;; unless we wanted a paste confirmation and declined + (unless (and webpaste/paste-confirmation + (not (yes-or-no-p "paste entire buffer?"))) + ;; Extract the buffer contents with buffer-substring and paste it + (webpaste-paste-text (buffer-substring (point-min) (point-max)))))