Debpaste is an Emacs interface for the Debian Paste Service. It provides receiving, posting and deleting pastes using XML-RPC.
Highlighting (i.e. enabling a major-mode depending on a paste language) is supported.
As usual you need to add this to your
(add-to-list 'load-path "/path/to/debpaste-dir")
After that you can either load the package on emacs start with:
or add a bunch of lines for autoloading functions and put into
eval-after-load what should be put there, for example:
(autoload 'debpaste-display-paste "debpaste" nil t) (autoload 'debpaste-paste-region "debpaste" nil t) (autoload 'debpaste-paste-buffer "debpaste" nil t) (autoload 'debpaste-delete-paste "debpaste" nil t) (with-eval-after-load 'debpaste (delete 'debpaste-display-received-info-in-minibuffer debpaste-received-filter-functions) (define-key debpaste-command-map "i" 'debpaste-display-received-info-in-buffer) (define-key debpaste-command-map "l" 'debpaste-display-posted-info-in-buffer))
The package can be installed from MELPA (with
M-x package-install or
Using and configuration
You can explore variables available for customizing with:
M-x customize-group RET debpaste
The package provides a keymap
debpaste-command-map with basic
commands. Example of binding and modifying the keymap:
(global-set-key (kbd "M-D") 'debpaste-command-map) (with-eval-after-load 'debpaste (define-key debpaste-command-map "mp" 'debpaste-display-posted-info-in-minibuffer) (define-key debpaste-command-map "mr" 'debpaste-display-received-info-in-minibuffer))
After that you can press
Meta-Shift-d m p for displaying information
of the last posted paste in minibuffer. And of course you can see key
Receiving a paste
You will be prompted for a paste ID (URL at point can help - see the docstring of that function). The received paste will be displayed in a separate buffer and additional information about the paste will be shown in the minibuffer. More info can be displayed using:
This info can be configured with the following variables:
Posting a paste
M-x debpaste-paste-region M-x debpaste-paste-buffer
With prefix, you will be prompted for posting options. Variables with default values of posting options:
After posting a paste, some information about the paste will be shown in minibuffer and a paste URL will be put into kill-ring. More info about the last posted paste can be displayed using:
Deleting a paste
You will be prompted for SHA1 digest of the paste (you receive it after posting a paste).
If you don’t like default names of debpaste buffers, you can modify them by configuring these variables:
Don’t forget to modify the last regexp: it is used for
(setq debpaste-received-paste-buffer-name-function (lambda (info) (format "Debian paste %s" (debpaste-get-param-val 'id info))) debpaste-received-info-buffer-name-function (lambda (info) (format " Useless info about the paste %s" (debpaste-get-param-val 'id info))) debpaste-posted-info-buffer-name-function debpaste-received-info-buffer-name-function debpaste-buffer-name-regexp "^Debian paste .*$\\|^ Useless info about the paste .*$")
The main points for hacking are variables with filter functions:
These functions can be used for editing/adding/removing info parameters
or for side effects like putting url into kill-ring or displaying info
in the minibuffer. See
debpaste-action for details.
For example, if you don’t want paste URL to be put into the kill-ring but want to see a message with some customized info after posting a paste, you can use something like this:
(setq debpaste-posted-filter-functions '(debpaste-filter-intern debpaste-filter-error-check debpaste-filter-url debpaste-save-last-posted-info debpaste-display-posted-info-in-minibuffer) debpaste-posted-info-minibuffer-params '(view-url download-url delete-url))
Instead of setting
debpaste-posted-filter-functions, you may use a
more complicated decision with
Isn’t it good to receive a paste with a proper major mode enabled?
debpaste-language-alist contains associations of languages
supported by the paste server and emacs major-modes. If you know what
mode can be used for a particular language or if you see errors in those
associations, you may mail me or open an issue.