Emacs client for http://paste.debian.net/
Alex Kost 6f2a400665 gitignore: Add "tmp" and "autoloads.el" | 8 anni fa | |
---|---|---|
.gitignore | 8 anni fa | |
README.org | 8 anni fa | |
debpaste.el | 9 anni fa |
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.
XmlRpc package is required. It can be installed from MELPA or Marmalade.
As usual you need to add this to your =.emacs=:
(add-to-list 'load-path "/path/to/debpaste-dir")
After that you can either load the package on emacs start with:
(require 'debpaste)
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
=M-x list-packages=).
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
bindings with M-D C-h
.
M-x debpaste-display-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:
M-x debpaste-display-received-info-in-buffer
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:
M-x debpaste-display-posted-info-in-bufferDeleting a paste
M-x debpaste-delete-paste
You will be prompted for SHA1 digest of the paste (you receive it after posting a paste).
Example:
(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 .*$")
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 delete
and add-to-list
functions.
Isn't it good to receive a paste with a proper major mode enabled?
A variable 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.