;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\305\306\307\310\311\312%\210\313\314\315\316\311\306\317\320&\210\321\322\323\324#\210\321\325\326\327#\207" [require url xml url-cache org-faces custom-declare-group wolfram-alpha nil "Wolfram Alpha customization group" :group wolfram custom-declare-variable wolfram-alpha-app-id "" "The Wolfram Alpha App ID." :type string custom-declare-face wolfram-query ((t (:inherit org-level-1))) "Face for the query string in the WolframAlpha buffer." wolfram-pod-title ((t (:inherit org-level-2))) "Face for the pod titles in search results in the WolframAlpha buffer."] 8) #@38 Name of WolframAlpha search buffer.  (defvar wolfram-alpha-buffer-name "*WolframAlpha*" (#$ . 720)) #@37 History for `wolfram-alpha' prompt. (defvar wolfram-alpha-query-history nil (#$ . 826)) #@98 Set the magnification factor. See https://products.wolframalpha.com/api/documentation/#width-mag (custom-declare-variable 'wolfram-alpha-magnification-factor 1.0 '(#$ . 920) :group 'wolfram-alpha :type 'number) #@33 Formats a WolframAlpha API url. (defalias 'wolfram--url-for-query #[(query) "\303\304\305 !\n$\207" [wolfram-alpha-app-id query wolfram-alpha-magnification-factor format "http://api.wolframalpha.com/v2/query?appid=%s&input=%s&format=image,plaintext&parsetimeout=15&scantimeout=15&podtimeout=15&formattimeout=15&mag=%s" url-hexify-string] 5 (#$ . 1137)]) #@25 Returns XML for a query (defalias 'wolfram--async-xml-for-query #[(query callback) "\303!\211\205r\304 \n\"q))\207" [query url callback wolfram--url-for-query url-retrieve] 4 (#$ . 1498)]) #@38 Appends a pod to the current buffer. (defalias 'wolfram--append-pod #[(pod) "\302\305\"\206\n\306\266\202\307\305\"\206\306\266\202\310\232\211\2051\311\312\313\n\314\315# \203/\316\2020\306#c\210\317\303\"\320\211\205M\f@\321 !\210\fA\211\204>\320,\207" [pod err title subpod --dolist-tail-- xml-get-attribute-or-nil "" error "true" format "\n## %s%s\n\n" propertize face wolfram-pod-title " *error*" xml-get-children nil wolfram--append-subpod] 7 (#$ . 1697)]) #@46 Inserts an image xml into the current buffer (defalias 'wolfram--insert-image #[(image) "\304\305\"\206\n\306\266\202\307\310!\311 !\312 !\210eb\210\313\314!\210\315ed\n#\210\316 \210\317 \210\320\321\n\"c\210db+\207" [image url temp-file data src xml-get-attribute-or-nil "" make-temp-file "wolfram" url-retrieve-synchronously switch-to-buffer search-forward "\n\n" write-region kill-buffer wolfram--switch-to-wolfram-buffer format "%s"] 5 (#$ . 2187)]) #@41 Appends a subpod to the current buffer. (defalias 'wolfram--append-subpod #[(subpod) "\303\302\"@\303\304\"@\211\203# \203#\305 \306\307\"\206\310\266\202!\210\n\2034 \2044\311\312\313\n!@\"c\210 \203K\n\204K\314 \306\307\"\206G\310\266\202!\210\315c*\207" [subpod image plaintext xml-get-children img wolfram--insert-image-from-url src xml-get-attribute-or-nil "" format "%s\n" last wolfram--insert-image "\n"] 7 (#$ . 2655)]) #@70 Switches to (creates if necessary) the wolfram alpha results buffer. (defalias 'wolfram--switch-to-wolfram-buffer #[nil "\302!p =\204\303 !\210\304 \210\305\306!\203\306 \210 )\207" [wolfram-alpha-buffer-name buffer get-buffer-create switch-to-buffer special-mode functionp iimage-mode] 2 (#$ . 3106)]) #@38 Creates the buffer to show the pods. (defalias 'wolfram--create-wolfram-buffer #[(query) "\302 \210db\210\303\304\305\306 \307\310#\"c)\207" [inhibit-read-only query wolfram--switch-to-wolfram-buffer t format "# \"%s\" (searching)\n" propertize face wolfram-query] 6 (#$ . 3421)]) #@181 Switch to WolframAlpha buffer and delete the "(searching)" notification. That notification indicates that the search is still in progress. This function removes that notification. (defalias 'wolfram--delete-in-progress-notification #[nil "\301 \210db\210\302\303!\210\304\305\306!\210)db\207" [inhibit-read-only wolfram--switch-to-wolfram-buffer search-backward " (searching)" t replace-match ""] 2 (#$ . 3710)]) #@52 Appends all pods from PODS to WolframAlpha buffer. (defalias 'wolfram--append-pods-to-buffer #[(pods) "\304 \210\305 \306\211\203 @\307\n!\210 A\211\204 *\310c)\207" [inhibit-read-only pods pod --dolist-tail-- wolfram--delete-in-progress-notification t nil wolfram--append-pod "\n"] 3 (#$ . 4130)]) #@48 Fetches an image and inserts it in the buffer. (defalias 'wolfram--insert-image-from-url #[(url) "\204\303\304!\210\305!\306\216r q\210eb\210\307\310!\210`d{)\311\312\n\313\314#!+\207" [url buffer data error "No URL." url-retrieve-synchronously #[nil "\301!\207" [buffer kill-buffer] 2] search-forward "\n\n" insert-image create-image nil t] 5 (#$ . 4443)]) #@61 Callback function to run after XML is returned for a query. (defalias 'wolfram--query-callback #[(_args) "\304 \305\306\307\310\"r q\210\311\216\312 \210c\210\313ed\"@+\314\"\211\203)\315\n!\210\2026\316 \210\310\317\320\321\322#c\210)\323\324!*\207" [data #1=#:temp-buffer pods inhibit-read-only buffer-string xml-get-children generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] erase-buffer xml-parse-region pod wolfram--append-pods-to-buffer wolfram--delete-in-progress-notification propertize "No results for your query.\n\n" face warning message ""] 5 (#$ . 4814)]) #@79 Sends a query to Wolfram Alpha, returns the resulting data as a list of pods. (defalias 'wolfram-alpha #[(query) "\302\300!\203\203\303\230\203\304\305!\210\306 !\210\307 \310\"\207" [wolfram-alpha-app-id query boundp "" error "Custom variable `wolfram-alpha-app-id' not set." wolfram--create-wolfram-buffer wolfram--async-xml-for-query wolfram--query-callback] 3 (#$ . 5442) (list (if (use-region-p) (buffer-substring-no-properties (region-beginning) (region-end)) (read-string "Query: " nil 'wolfram-alpha-history)))]) (provide 'wolfram)