
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!
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.
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 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.
Fetches the paste by the specified id and inserts it into a new buffer.
Fetches the paste by the specified id and inserts it into the current buffer at the point.
Fetches the last paste and inserts it into a new buffer.
Fetches the last paste and inserts it into the current buffer at the point.
Creates a new paste out of the region from start to end. language defines the paste language, which is used for server-side highlighting.
Creates a new paste from the contents of buffer. language has the same meaning as for (paste-new-from-region).
Creates a global menu to access the paste functions.
There are two configuration variables, that tune the behaviour of pastemacs:
If non-nil, the url of a newly created paste is put into kill ring for later use.
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.