From cb9cca769b04804ab73cb5e6c0bf4df4f8eddfb7 Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sat, 8 Oct 2016 22:39:13 +0200 Subject: [PATCH] Stop moving point and remove usage of save-excursion and therefore simplify the code greatly. --- webpaste.el | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/webpaste.el b/webpaste.el index d102fc0..ef2a7d1 100644 --- a/webpaste.el +++ b/webpaste.el @@ -177,16 +177,8 @@ When we run out of providers to try, it will restart since "Paste selected region to some paste service." (interactive) - (let ((text (buffer-substring (mark) (point)))) - (webpaste-paste-text text))) - - -;;;###autoload -(defmacro webpaste-save-mark-and-excursion (&rest body) - "Wraps usage of sending BODY to ‘save-mark-and-excursion’ / ‘save-excursion’." - (if (< emacs-major-version 25) - `(save-excursion ,@body) - `(save-mark-and-excursion ,@body))) + ;; Extract the buffer contents with buffer-substring and paste it + (webpaste-paste-text (buffer-substring (mark) (point)))) ;;;###autoload @@ -194,10 +186,8 @@ When we run out of providers to try, it will restart since "Paste current buffer to some paste service." (interactive) - (webpaste-save-mark-and-excursion - (set-mark (point-min)) ; Set mark on point-min - (goto-char (point-max)) ; Go to point-max - (webpaste-paste-region))) ; Paste region + ;; Extract the buffer contents with buffer-substring and paste it + (webpaste-paste-text (buffer-substring (point-min) (point-max)))) (provide 'webpaste)