Skip to content

Instantly share code, notes, and snippets.

@lynaghk
Created March 29, 2024 08:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynaghk/613465c834a826a5344b99b5b10e7c45 to your computer and use it in GitHub Desktop.
Save lynaghk/613465c834a826a5344b99b5b10e7c45 to your computer and use it in GitHub Desktop.
Copy markdown from Emacs, paste formatted content directly into GMail
(defun formatted-copy ()
"Export region to HTML, and copy it to the clipboard."
(interactive)
(save-window-excursion
(let* ((buf (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t))
(html (with-current-buffer buf (buffer-string))))
(with-current-buffer buf
(shell-command-on-region
(point-min)
(point-max)
"pandoc -f gfm -t html5 | pbcopy_html"))
(kill-buffer buf))))
(global-set-key (kbd "C-M-c") 'formatted-copy)
#!/usr/bin/env swift
import Cocoa
import Darwin
let pasteboard = NSPasteboard.general
guard let data = try? FileHandle.standardInput.readToEnd() else {
exit(1)
}
pasteboard.clearContents()
pasteboard.setData(data, forType: .html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment