emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-decrypt-to-kill-ring
@ 2010-06-23 18:51 Raymond Zeitler
  0 siblings, 0 replies; only message in thread
From: Raymond Zeitler @ 2010-06-23 18:51 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Raymond Zeitler

Hi All:

I'm a new org-mode user because someone suggested that I could use
org-crypt to build a platform-independent password manager in Emacs.
And because Sacha uses Org. :)

First of all, I really like Org-mode.  Thank you for all the work you've
put into it!

Getting org-crypt to work was not straight-forward for me because I'm
working on Windows, and there is no native GPG program.  But I followed
the code from org-crypt to egp.el and finally to the GnuGP port for
Windows.  Whew.

Anyway, I thought it would be handy to decrypt directly to the
clipboard, er, excuse me, kill-ring, rather than decrypt and then M-w.
So I made a new function `org-decrypt-to-kill-ring' based entirely on
`org-decrypt-entry'.  I'm certainly not a Lisp expert, but I can copy
and make tiny changes to code, as I've done here.  I have this bound to
C-c M-w.  I thought I'd share it in case it might help someone:

(defun org-decrypt-to-kill-ring ()
  "Save to the kill ring the decrypted content of the current headline.
Based on `org-decrypt-entry' from org-crypt.el version 6.36c."
  (interactive)
  (require 'epg)
  (save-excursion
    (org-back-to-heading t)
    (forward-line)
    (when (looking-at "-----BEGIN PGP MESSAGE-----")
      (let* ((beg (point))
             (end (save-excursion
                    (search-forward "-----END PGP MESSAGE-----")
                    (forward-line)
                    (point)))
             (epg-context (epg-make-context nil t t))
             (decrypted-text
	      (decode-coding-string
	       (epg-decrypt-string
		epg-context
		(buffer-substring-no-properties beg end))
	       'utf-8)))
        (kill-new decrypted-text)
        nil))))


Incidentally, the lines in my encrypted content all have an extra 0x0D
character at the end.  I assume it's a by-product of using Unix-y tools
on Windows  Anyway, it doesn't mess up anything.

I'll be updating my emacswiki page soon....

- Ray

--
Raymond Zeitler <r.zeitler@ieee.org> 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-23 19:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-23 18:51 org-decrypt-to-kill-ring Raymond Zeitler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).