diff --git a/README.org b/README.org index e15ac00..5aaaa1e 100644 --- a/README.org +++ b/README.org @@ -17,6 +17,21 @@ The package is available on MELPA. Install it however you normally install packa Or clone the repository, add it to =load-path=, and =require= the package. +** Issues with termux? +I've been trying to run this package on termux and had some issues. + +First, for some reason =request.el= throws the successfully parsed response as error. Use this as a workaround: +#+begin_src emacs-lisp +(setq biome-api-try-parse-error-as-response t) +#+end_src + +Second, somehow the == is not the same as the == key. The following might be neccessary: +#+begin_src emacs-lisp +(setq biome-query-tab-key "") +#+end_src + +Be sure to add that before the package initialization. + * Usage The main entry point is =M-x biome=. Each item under "Open Meteo Data" corresponds to a particular endpoint of the service. For instance, =M-x biome ww= is a generic weather forecast. Check out the [[https://open-meteo.com/en/docs][API docs]] for more detailed descriptions. diff --git a/biome-api.el b/biome-api.el index ecdbb77..169c1f7 100644 --- a/biome-api.el +++ b/biome-api.el @@ -45,6 +45,14 @@ ("Flood" . "https://flood-api.open-meteo.com/v1/flood")) "Default URLs for Open Meteo API.") +(defcustom biome-api-try-parse-error-as-response nil + "Try to parse error responses as normal ones. + +This is a workaround for my termux setup, somehow request' gives +the parsed response to the error callback there." + :group 'biome + :type 'boolean) + (defcustom biome-api-urls biome-api--default-urls "URLs of the Open Meteo API." :type `(alist @@ -91,7 +99,7 @@ QUERY is a form as defined by `biome-query-current'." \\{biome-api-error-mode-map}" (read-only-mode 1)) -(defun biome-api--show-error (error-thrown response) +(defun biome-api--show-error (error-thrown response &optional err) "Show ERROR-THROWN and RESPONSE in a buffer." (let ((buffer (generate-new-buffer "*biome-api-error*"))) (with-current-buffer buffer @@ -100,6 +108,11 @@ QUERY is a form as defined by `biome-query-current'." (propertize "Error: " 'face 'font-lock-warning-face) (prin1-to-string error-thrown) "\n") + (when err + (insert + (propertize "Pasing error: " 'face 'font-lock-warning-face) + (error-message-string err) + "\n")) (condition-case nil (insert (propertize "Reason: " 'face 'font-lock-warning-face) (alist-get 'reason (request-response-data response)) @@ -125,8 +138,12 @@ called with QUERY and the data returned by the API as arguments." (lambda (&key data &allow-other-keys) (funcall callback (copy-tree query) data))) :error - (cl-function (lambda (&key error-thrown response &allow-other-keys) - (biome-api--show-error error-thrown response)))))) + (cl-function + (lambda (&key error-thrown response &allow-other-keys) + (if biome-api-try-parse-error-as-response + (condition-case err + (funcall callback (copy-tree query) (request-response-data response)) + (error (biome-api--show-error error-thrown response err))))))))) (defun biome-api-get-multiple (queries callback) "Get data from Open Meteo API. diff --git a/biome-query.el b/biome-query.el index 3a97e6a..1404700 100644 --- a/biome-query.el +++ b/biome-query.el @@ -84,6 +84,11 @@ The format is: (name latitude longitude)." (string :tag "Column name"))) :group 'biome) +(defcustom biome-query-tab-key "" + "Key used for TAB." + :type 'string + :group 'biome) + (defconst biome-query-groups '("daily" "hourly" "minutely_15" "hourly") "Name of groups. @@ -629,7 +634,7 @@ OBJ is an instance of `biome-query--transient-group-switch'." (transient-define-infix biome-query--transient-group-switch-infix () :class 'biome-query--transient-group-switch - :key "" + :key biome-query-tab-key :description "Switch group") ;; Layout generation