From: "Raymond Zeitler" <rzeitler@phonon.com>
To: emacs-orgmode@gnu.org
Cc: Raymond Zeitler <r.zeitler@ieee.org>
Subject: org-decrypt-to-kill-ring
Date: Wed, 23 Jun 2010 14:51:03 -0400 [thread overview]
Message-ID: <62E0EB638E69B146AE708525ABB775B201D6733C@PHONONEXCHANGENEW.PHONON.COM> (raw)
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>
reply other threads:[~2010-06-23 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=62E0EB638E69B146AE708525ABB775B201D6733C@PHONONEXCHANGENEW.PHONON.COM \
--to=rzeitler@phonon.com \
--cc=emacs-orgmode@gnu.org \
--cc=r.zeitler@ieee.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).