Skip to content
Emacs function to copy buffer locations as GitHub/Slack/JIRA etc... formatted code
Emacs Lisp
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Dec 3, 2016
README.md Use defgroup instead of defvar May 23, 2019
copy-as-format.el Use defgroup instead of defvar May 23, 2019
demo.gif Add demo GIF Dec 4, 2016

README.md

copy-as-format

MELPA

Emacs function to copy buffer locations as GitHub/Slack/JIRA etc... formatted code

copy-as-format demo

Supported Formats/Services

  • AsciiDoc
  • Bitbucket
  • Disqus
  • GitHub
  • GitLab
  • HipChat
  • HTML
  • JIRA
  • Markdown
  • MediaWiki
  • Org-mode
  • POD
  • reStructuredText
  • Slack

Usage

M-x copy-as-format or C-u M-x copy-as-format

Copy the current line or active region and add it to the kill ring as GitHub/Slack/JIRA/HipChat/... formatted code. Format defaults to copy-as-format-default. The buffer will not be modified.

With a prefix argument prompt for the format.

M-x copy-as-format-SERVICE

Where SERVICE is one of the supported services.

It's a good idea to bind these functions to a key sequence:

(global-set-key (kbd "C-c w s") 'copy-as-format-slack)
(global-set-key (kbd "C-c w g") 'copy-as-format-github)

For AsciiDoc customization see copy-as-format-asciidoc-include-file-name and copy-as-format-asciidoc-language-alist.

Adding Formats

Create a format function with a signature of TEXT MULTILINE:

  • TEXT - the text to be formatted
  • MULTILINE - t if TEXT spans multiple lines, otherwise nil

For example:

(defun some-great-format (text multiline)
  (if multiline
      (multiline-format text)
    (single-line-format text)))

Then, add an entry to copy-as-format-format-alist. The key is the format's name and the value is the format function:

(add-to-list 'copy-as-format-format-alist '("great-format" some-great-format))

See Also

You can’t perform that action at this time.