[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste 07a85e9 142/298: Added pre-calculated alist of la
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste 07a85e9 142/298: Added pre-calculated alist of languages for providers |
Date: |
Thu, 9 Dec 2021 19:00:01 -0500 (EST) |
branch: elpa/webpaste
commit 07a85e9f4406d4484bab7eda33bfa6d897100d5b
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>
Added pre-calculated alist of languages for providers
This is because we want to have access to overrides of langs for
providers that requires that we append this data after the request has
happened. So it was easier to just precalculate them for all the
providers so we don't need special handling more than neccesary.
---
webpaste.el | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/webpaste.el b/webpaste.el
index fc7d717..e04eae6 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -80,6 +80,12 @@ This list will be re-populated each run based on
‘webpaste-provider-priority
if that variable is nil, it will use the list of names from
‘webpaste-providers’
each run.")
+
+(defvar webpaste/provider-lang-alists ()
+ "Variable for storing alists with languages for highlighting for providers.
+This list will be populated when you add providers to have the languages
+precalculated, and also available both for pre and post request access.")
+
;;; Predefined error lambda for providers
@@ -118,17 +124,19 @@ each run.")
(defvar webpaste/providers-default-post-field-lambda
(cl-function (lambda (&key text
post-field
+ provider-uri
(post-lang-field-name nil)
(lang-overrides nil)
(post-data '()))
(cl-pushnew (cons post-field text) post-data)
- (when post-lang-field-name
- ;; Get language name based on major-mode
- (let ((language-name (cdr (assoc major-mode
(webpaste/get-lang-alist-with-overrides lang-overrides)))))
+ ;; Fetch alist of languages for this provider
+ (let ((provider-lang-alist (cdr (assoc provider-uri
webpaste/provider-lang-alists))))
+ ;; Fetch language name for this major mode for this provider
+ (let ((language-name (cdr (assoc major-mode
provider-lang-alist))))
;; If not set correctly, get the fundamental-mode one
which should be plaintext
(unless language-name
- (setq language-name (cdr (assoc 'fundamental-mode
(webpaste/get-lang-alist-with-overrides lang-overrides)))))
+ (setq language-name (cdr (assoc 'fundamental-mode
provider-lang-alist))))
;; Append language to the post-data
(cl-pushnew (cons post-lang-field-name language-name)
post-data)))
@@ -214,6 +222,10 @@ Optional params:
:sync Set to t to wait until request is done. Defaults to nil.
This should only be used for debugging purposes."
+ ;; Add pre-calculated list of webpaste lang alists
+ (cl-pushnew (cons uri (webpaste/get-lang-alist-with-overrides
lang-overrides))
+ webpaste/provider-lang-alists)
+
(lambda (text)
"Paste TEXT to provider"
@@ -223,6 +235,7 @@ Optional params:
:type type
:data (funcall post-field-lambda
:text text
+ :provider-uri uri
:post-field post-field
:post-lang-field-name post-lang-field-name
:lang-overrides lang-overrides
- [nongnu] elpa/webpaste 382e01d 105/298: Added page breaks to files, (continued)
- [nongnu] elpa/webpaste 382e01d 105/298: Added page breaks to files, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b7acc4e 100/298: Added test for returning of URL's, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8027e6e 106/298: Run tests on emacs 25.2 since it's been released, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e04d885 114/298: Add (prog1 nil ...) form to avoid having the nil hanging at the end, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 124ef8b 119/298: Drop usage of concat when returning link to users message field, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 69166a3 121/298: Moved error-handling of failed requests out so providers must specify it, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 69f9452 122/298: Bump version for minor release, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8905a52 125/298: Re-arrange arguments to webpaste-provider and update docs, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 72ba31e 127/298: Bump version for new release, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7d03ed3 137/298: Removed unused variables defined in function declaration, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 07a85e9 142/298: Added pre-calculated alist of languages for providers,
ELPA Syncer <=
- [nongnu] elpa/webpaste 7b84568 155/298: Avoid setq's in favor of let, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 0c0e88a 079/298: Added basic structure of tests file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 95289e5 082/298: Added .travis.yml config file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7c90bc5 090/298: Merge branch 'tarsius-master', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ec85d7d 092/298: Added unit test for static provider configuration, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 2c5eb3c 149/298: Fix broken build., ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste f161620 163/298: Refactored the success callbacks, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste dab97dd 130/298: Make post-fields-lambda take named parameters, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste f83fd7b 145/298: Added note about new provider to implement. This refs #7, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 62e0f33 165/298: Refactor default post field lambda, ELPA Syncer, 2021/12/09