Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Raymond Zeitler <rzeitler <at> phonon.com>
Subject: org-decrypt-to-kill-ring
Newsgroups: gmane.emacs.orgmode
Date: Wednesday 23rd June 2010 18:51:03 UTC (over 6 years ago)
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  

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
 
CD: 4ms