a violet pig being the logo of this site

pastemacs – Access Lodgeit from emacs

Pastebins like the excellent Lodgeit are the preferred way of publishing longer code snippets in web forums or IRC. But being web applications, they usually don’t integrate with your favourite editor (mine is emacs), which ends in terribly inconvenient copy n’ paste action... but not the Lodgeit. When I discovered, that it exposed its functionality through a XML RPC service, the idea for this Pymacs script was born. It brings emacs and the Lodgeit together in a very convenient way!

Download

pastemacs is easy_installable, so you won’t need to download it manually. See Installation for details. But for the sake of completeness here is the link: pastemacs

Mercurial repo is available at BitBucket.

Installation

You need Python (at least version 2.5) installed and working. pastemace itself is easy_installable:

easy_install pastemacs

This will install the following dependencies on your system, if there are not already present:

Moreover you need a working installation of Pymacs. This is the more difficult part of installation procedure, refer to the Pymacs documentation for help and/or consult your system vendors documentation on how to install software. If Pymacs is working and add the line (pymacs-load "pastemacs" "paste-").

Note

Unlike Python, elisp doesn’t know about namespaces, which is why python functions need to be prefixed to avoid name clashes. The above call uses the prefix paste- for all functions from pastemacs. Of course, you can change the prefix, but this is absolutely not recommended, because it breaks (paste-menu).

Usage

Usage is quite simple. pastemacs exposes some interactive functions, which query their arguments from the minibuffer. You can invoke these function M-x RET functionname or assign them to a keyboard sequence. You can also call (paste-menu) somewhere in your ~/.emacs and thus add a convenient menu to emacs.

Available functions

(paste-fetch-by-id id)

Fetches the paste by the specified id and inserts it into a new buffer.

(paste-insert-by-id id)

Fetches the paste by the specified id and inserts it into the current buffer at the point.

(paste-fetch-last)

Fetches the last paste and inserts it into a new buffer.

(paste-insert-last)

Fetches the last paste and inserts it into the current buffer at the point.

(paste-new-from-region start end language)

Creates a new paste out of the region from start to end. language defines the paste language, which is used for server-side highlighting.

(new_from_buffer buffer language)

Creates a new paste from the contents of buffer. language has the same meaning as for (paste-new-from-region).

(paste-menu)

Creates a global menu to access the paste functions.

Configuration

There are two configuration variables, that tune the behaviour of pastemacs:

paste-kill-url

If non-nil, the url of a newly created paste is put into kill ring for later use.

paste-show-in-browser

If non-nil, any newly created paste is opened in your favourite web browser.

Both variables can either be changed through the customization group pastebin or directly in your ~/.emacs.

Bugs

Please report any bugs to the tracker.

License

This programm is free software, you can redistribute and/or modify it under the terms of the GPL 2.