[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] org-decrypt-to-kill-ring
From: |
Raymond Zeitler |
Subject: |
[Orgmode] org-decrypt-to-kill-ring |
Date: |
Wed, 23 Jun 2010 14:51:03 -0400 |
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 <address@hidden>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Orgmode] org-decrypt-to-kill-ring,
Raymond Zeitler <=