Coder Social home page Coder Social logo

wolfram.el's Introduction

MELPA

Wolfram Alpha integration in Emacs

Allows you to query Wolfram Alpha from within Emacs.

Installation

Install package wolfram from MELPA or download wolfram.el to a directory in your load-path. Then add this to your init file:

(require 'wolfram)

Variables

Wolfram Alpha App ID

Create an account at wolframalpha.com, then in your account select "My Apps (API)". Create a new AppID. In Emacs set that AppID as the custom variable wolfram-alpha-app-id.

Optional Dark Mode

Enable dark mode by setting wolfram-use-dark-version to t in your configuration file. Dark mode requires ImageMagick's convert utility to invert images for a dark theme. Without ImageMagick installed, image inversion will not function, and a warning will be displayed if dark mode is enabled.

(setq wolfram-use-dark-version t)

Magnification Factor

Adjust the magnification factor for images in query results using the custom variable wolfram-alpha-magnification-factor. A higher value results in larger images.

(setq wolfram-alpha-magnification-factor 1.5)

Set the factor according to your viewing preferences and display resolution.

Usage

To make a query, run M-x wolfram-alpha then type your query. It will show the result in a buffer called *WolframAlpha*.

Examples

Weather in Mombasa (dark-mode enabled)

Weather in Mombasa

How much does Lake Victoria weigh?

How much does Lake Victoria weigh?

How many nukes does the United State have?

How many nukes does the United State have?

wolfram.el's People

Contributors

hsjunnesson avatar kaushalmodi avatar mssdvd avatar stardiviner avatar ziova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wolfram.el's Issues

Character coding is not correct

When inserting the plaintext response from the API the unicode characters do not display correctly showing instead as octal code.

Missing license

This package doesn't have a license. If all contributors agree I would opt for the GPL v3.

Doesn't work in terminal

The code seems to only insert images and not plaintext if an image is returned by Wolfram alpha and because images don't work when in the terminal nothing is shown in that case.

Images should not be inserted when in the terminal.
Plaintext should probably always be inserted (or at least have a setting).

(defun wolfram--append-subpod (subpod)
  "Appends a subpod to the current buffer."
  (let ((plaintext (car (xml-get-children subpod 'plaintext)))
        (image (car (xml-get-children subpod 'img))))
    (if (and image window-system)
        (wolfram--insert-image-from-url (xml-get-attribute image 'src)))
    (insert (format "%s\n" (car (last plaintext))))
    (insert "\n")))

I don't understand what wolfram--insert-image does (vs. Wolfram--insert-image-from-url)

Throw an error if num-pods is 0 for a query

Hi,

Here is an example query: "How much sugar does an orange have?".

If I use that as a query, all I see in the *WolframAlpha* buffer is:

# "How much sugar does an orange have? (searching)"

.. and after few seconds, that changes to:

# "How much sugar does an orange have?"

There is no indication that that search turned up with 0 results.

If I enter that API call in browser:

http://api.wolframalpha.com/v2/query?appid=<YOUR_APPID>&input=How%20much%20sugar%20does%20an%20orange%20have%3F&format=image,plaintext&parsetimeout=15&scantimeout=15&podtimeout=15&formattimeout=15

Just put in <YOUR_APPID> above.

I get

<queryresult success="false" error="false" numpods="0" datatypes="" timedout="" timedoutpods="" timing="5.513" parsetiming="1.44" parsetimedout="false" recalculate="" id="" host="http://www4f.wolframalpha.com" server="16" related="" version="2.6">
    <didyoumeans count="1">
        <didyoumean score="0.315076" level="medium">sugar orange</didyoumean>
    </didyoumeans>
</queryresult>

Suggestion

Show a message to the user along the lines that that query turned up with no results (as numpods="0").

Make the *WolframAlpha* buffer read-only

Can you please set the *WolframAlpha* buffer in special-mode so that the bindings like q work for killing the window.

When you are populating the buffer with "pods" in wolfram--append-pods-to-buffer, you can let-bind inhibiti-read-only to t so that the special-mode buffer is writable only within that function. What do you think?

Usage instructions? App ID?

This seems to be the only emacs integration with Wolfram Alpha. I'm interested in using it. When I run (wolfram-alpha) it returns instantly with nothing but a new buffer with my query as an Org headline. There are no errors reported in *Messages*. I signed up for an App ID and set that in the code, but it also doesn't change anything. If I manually paste the URL it appears your code generates, with my App ID, Alpha replies,

URL: http://api.wolframalpha.com/v2/query?appid=MY_APP_ID_HERE&input="40+2"&format=image,plaintext&parsetimeout=15&scantimeout=15&podtimeout=15&formattimeout=15

<queryresult success="false" error="true" numpods="0" datatypes="" timedout="" timedoutpods="" timing="0.032" parsetiming="0." parsetimedout="false" recalculate="" id="" host="http://www5a.wolframalpha.com" server="55" related="" version="2.6" profile="EnterDoQuery:0.,StartWrap:0.032011">
<error>
<code>1</code>
<msg>Invalid appid</msg>
</error>
</queryresult>

[Feature Request]

Change image background color, this would be fantastic for those who have a dark theme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.