emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/webpaste 51b20d9 235/298: Merge branch 'WP-25-raw-pastes'


From: ELPA Syncer
Subject: [nongnu] elpa/webpaste 51b20d9 235/298: Merge branch 'WP-25-raw-pastes'
Date: Thu, 9 Dec 2021 19:00:21 -0500 (EST)

branch: elpa/webpaste
commit 51b20d98145c8d94d416d9794c11969c0b22f71c
Merge: b8e9245 9c5e921
Author: Elis Hirwing <elis@hirwing.se>
Commit: Elis Hirwing <elis@hirwing.se>

    Merge branch 'WP-25-raw-pastes'
---
 README.org                                            | 11 +++++++++++
 tests/unit/test-webpaste-default-post-field-lambda.el | 17 ++++++++++++++++-
 webpaste.el                                           | 13 ++++++++++---
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index ece5046..37176e2 100644
--- a/README.org
+++ b/README.org
@@ -69,6 +69,17 @@ This can be added to the =:config= section of use-package:
       (setq webpaste-provider-priority '("ptpb.pw" "dpaste.de"))))
 #+END_SRC
 
+** Only paste plaintext pastes
+If you don't want language detection you can define the following parameter
+that will tell the language detection to not check what language it is and
+not return anything to make it fallback to plaintext.
+
+Example:
+#+begin_src emacs-lisp
+  ;; Only paste raw pastes
+  (setq webpaste-paste-raw-text t)
+#+end_src
+
 ** Confirm pasting with a yes/no confirmation before pasting
 To enable a confirmation dialog to always pop up and require you to confirm
 pasting before text is actually sent to a paste-provider you just need to set
diff --git a/tests/unit/test-webpaste-default-post-field-lambda.el 
b/tests/unit/test-webpaste-default-post-field-lambda.el
index 3666037..022fcb6 100644
--- a/tests/unit/test-webpaste-default-post-field-lambda.el
+++ b/tests/unit/test-webpaste-default-post-field-lambda.el
@@ -21,7 +21,22 @@
                               :post-data '(("duration" . "1 day")))))
       (expect post-data
               :to-equal
-              '(("lang" . "text") ("content" . "my text") ("duration" . "1 
day")))))))
+              '(("lang" . "text") ("content" . "my text") ("duration" . "1 
day"))))))
 
+ (it
+  "can paste raw pastes"
+  (let ((post-lambda (webpaste--providers-default-post-field-lambda))
+        (major-mode 'fundamental-mode)
+        (webpaste-paste-raw-text t)
+        (webpaste--provider-lang-alists '(("https://example.com/"; . 
((fundamental-mode . "text"))))))
+    (let ((post-data (funcall post-lambda
+                              :text "my text"
+                              :post-field "content"
+                              :provider-uri "https://example.com/";
+                              :post-lang-field-name "lang"
+                              :post-data '(("duration" . "1 day")))))
+      (expect post-data
+              :to-equal
+              '(("content" . "my text") ("duration" . "1 day")))))))
 
 ;;; test-webpaste-default-post-field-lambda.el ends here
diff --git a/webpaste.el b/webpaste.el
index 344c933..4ab23a5 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -74,6 +74,12 @@ This uses `browse-url-generic' to open URLs."
   :type 'boolean)
 
 
+(defcustom webpaste-paste-raw-text nil
+  "Enable this to disable language detection to only make raw pastes."
+  :group 'webpaste
+  :type 'boolean)
+
+
 (defcustom webpaste-return-url-hook nil
   "Hook executed with the returned url as parameter."
   :group 'webpaste
@@ -403,9 +409,10 @@ Optional params:
 This also depends on which provider it is since different providers might have
 different opinions of how the input for their fields should look like."
 
-  (let ((provider-lang-alist (cdr (assoc provider 
webpaste--provider-lang-alists))))
-    (let ((language-name (cdr (assoc major-mode provider-lang-alist))))
-      language-name)))
+  (unless webpaste-paste-raw-text
+    (let ((provider-lang-alist (cdr (assoc provider 
webpaste--provider-lang-alists))))
+      (let ((language-name (cdr (assoc major-mode provider-lang-alist))))
+        language-name))))
 
 
 (cl-defun webpaste--return-url (returned-url)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]