Using Github Gist in EMACS

(Last Updated On: July 4, 2018)

In this post, I will show you how you can work with Github Gist in EMACS.  This is useful for saving snippets of code straight from EMACS.

Installing Github Gist for EMACS

Our first step will be to install the gist.el package for EMACS.  First we need to list all the packages.

M-x package-list-packages RET

Find the gist.el package in the list.  It will be a line for ‘gist’.

Hit i then x on that line to install the package.  After the package is installed, go back to your main EMACS screen.  First lets list our current gists by running the following command:

M-x gist-list RET

The first time you do this it will ask for your github username and password.  After you enter those in you will be presented with your current list of Gists (providing you actually have any).  Here it shows my one existing Gist:

This corresponds exactly with what I have from the web page:

If you hit RET then EMACS will open the gist in a new split window.  From here you can edit as normal.  Save it like you always do with C-x s.

Create a new gist

Now we can edit existing Gists, lets create a new Gist from EMACS.  Exit EMACS and and run the following command to create a new file called

$ emacs

Add the following code the file and save it.

## Simple gist to show how to do a python unary if statement

flag = "True"
result = True if flag == "True" else False

Mark the whole bit of code as a region.  Start at the beginning of the text and hit C-Space then highlight all the code.  Save the Gist by running the following the command:

M-x gist-region RET

Or to create a private Gist use this command:

M-x gist-region-private RET

Now you should be able to see your new Gist on the web page:

Pretty cool stuff and should make your life easier.  As always, I hope you enjoyed this post on Github Gist in EMACS.  Please leave me a comment below and if you haven’t yet sign up for my newsletter.


I hope you have enjoyed this article, if so please leave a comment below.  For more articles, please signup for the AdminTome Blog below.  Also please feel free to share the article to your friends using the buttons to the left.  Thanks again for reading this post.


1 thought on “Using Github Gist in EMACS

Leave a Comment

you're currently offline