Git Product home page Git Product logo

emacs-howdoi's Introduction

Howdoi.el -- instant coding answers via Emacs.

Do you find yourself constantly Googling for how to do basic programing tasks? Suppose you want to know how to format a date in bash. Why open your browser and read through blogs when you can just M-x howdoi-query RET format date bash RET

Howdoi.el is a way to query Stack Overflow directly from the Emacs and get back the most upvoted answer to the first question that comes up for that query.

Installation

Copy howdoi.el file to the ~/.emacs.d/ folder and put the line

(load-file "~/.emacs.d/howdoi.el")

into the ~/.emacs configuration file.

Usage

The following two commands show an answer in a pop up buffer:

 M-x howdoi-query RET <your-query> RET ;; e.g.: M-x howdoi-query RET format date bash RET
 M-x howdoi-query-line-at-point ;; takes a query from a line at point and shows an answer in a pop up buffer.

To get an answer containing only code snippet you could use:

 M-x howdoi-query-line-at-point-replace-by-code-snippet

this command replaces current line with a code snippet parsed from an answer or do

 M-x howdoi-query-insert-code-snippet-at-point

to get a code snippet for given query. The code snippet is inserted at point.

With that command you could get situation when it returns not good enough code snippet. Or may be after that command you would like to get more details which relates to the original query. Then you could use the following command:

M-x howdoi-show-current-question

This one will show (in a pop up buffer) full answer which contains recently inserted code snippet. This command may help sometimes to avoid additional googling when original query is a little bit ambiguous.

By default pop up buffer displays only answers. You could change howdoi-display-question custom variable to show also a question.

In the mentioned pop up buffer enables HowDoI major-mode. There are such key bindings are available:

  • n - howdoi-show-next-question
  • p - howdoi-show-previous-question
  • b - howdoi-browse-current-question
  • u - howdoi-query
  • < - beginning-of-buffer
  • > - end-of-buffer
  • q - quit window

There is also howdoi-minor-mode available with a list of key bindings:

  • C-c C-o n - howdoi-show-next-question
  • C-c C-o p - howdoi-show-previous-question
  • C-c C-o c - howdoi-show-current-question
  • C-c C-o b - howdoi-browse-current-question
  • C-c C-o u - howdoi-query
  • C-c C-o l - howdoi-query-line-at-point
  • C-c C-o r - howdoi-query-line-at-point-replace-by-code-snippet

Example

For example there is the line in the scratch buffer:

python file exists

point is located somewhere on this line.

After M-x howdoi-query-line-at-point-replace-by-code-snippet this line will be replaced by something like the following:

try:
   with open('filename'):
       process()
   except IOError:
       print 'Oh dear.'

Other example: there is the line in the scratch buffer:

elisp split string

After M-x howdoi-query-line-at-point-replace-by-code-snippet this line will be replaced by:

(split-string "1.2.3" "\.")

You may be wondered: why "." is escaped with two ''? You could execute then M-x howdoi-show-current-question and the full answer will be shown so you'll be able to get an explanation.

And last example: just execute M-x howdoi-query RET howdoi RET and it will return an answer in a pop up buffer.

In a pop up buffer you could press "n" to view next question, "p" to view previous question and "b" to browse question in a www browser.

Author

Andrey Tykhonov (atykhonov at gmail.com; @atykhonov)

Notes

Please contribute if you like too! :) Otherwise write down your suggestions, comments, feature requests etc etc etc.

Thank you! And Enjoy!

Contributors

emacs-howdoi's People

Contributors

atykhonov avatar jedrz 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

Watchers

 avatar  avatar  avatar  avatar

emacs-howdoi's Issues

Getting a blank buffer

Dear @atykhonov ,

I re-discovered this package - was in my huge config file, but did not know about it anymore. Now that I want to reuse it, as it seems particularly wise and useful, I have an empty buffer popping up…

Is this still working?

answer not getting popped to buffer

I installed from MELPA with emacs 24.4.2, and find that howoi-query and howdoi-query-line-at-point don't manage to put anything in the How do I buffer. howdoi-query-insert-code-snippet-at-point and hodoi-query-line-at-point-replace-by-code-snippet both work, so retrieving the answer from SO seams to be fine, but for some reason it is not getting inserted into the actual How do I buffer. Please let me know if you need further details in order to reproduce.

Query reject on the second question

The first query is pretty well processed, but after the second one I got this error:

error in process sentinel: Invalid date: 01-Jan-2055 00:00:00.00 GMT

and several seconds later the empty buffer How Do I (with no data at all) accomplished with this message:

Answer retrieved!

Thanks a lot 👍

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.