From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Raymond Zeitler" Subject: org-decrypt-to-kill-ring Date: Wed, 23 Jun 2010 14:51:03 -0400 Message-ID: <62E0EB638E69B146AE708525ABB775B201D6733C@PHONONEXCHANGENEW.PHONON.COM> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=36359 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORVO0-00073W-CJ for emacs-orgmode@gnu.org; Wed, 23 Jun 2010 15:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORVNz-0007nu-0x for emacs-orgmode@gnu.org; Wed, 23 Jun 2010 15:13:24 -0400 Received: from 63-144-137-67.dia.static.qwest.net ([63.144.137.67]:12009 helo=mail.phonon.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORVNy-0007nZ-Np for emacs-orgmode@gnu.org; Wed, 23 Jun 2010 15:13:22 -0400 Content-class: urn:content-classes:message List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 =20