views:

115

answers:

2

I am trying to add special handling to emacs to handle Triple-DES encrypted files (any file with extension .des3 is assumed to be a valid encrypted text file).

My approach is to append to format-alist, like so:

(setq format-alist 
      (cons (list 'des3 "Triple-DES encrypted files"
            ".*\.des3" "show" "" t nil)
          format-alist))

Where show is the following command-line script (verified working from the command line):

#!/bin/sh
openssl des3 -d -in $1

Expected: When opening a .des3 file I will be prompted for a password (by show) and then see the cleartext context in the emacs buffer. [note: I will also add save/encrypt later, but for now I want to get open working]

Actual: When opening a .des3 file, I do not get a prompt from show, or any indication that show has been called, and the buffer contains the encrypted file contents.

+3  A: 

format-alist is applied to the file contents, not its name. I think you want file-name-handler-alist instead. See Making Certain File Names "Magic" in the Emacs manual for more information.

Sean
+1  A: 

You want to look at ps-ccrypt.el for inspiration. It's a package that integrates with ccrypt. It does what your want for .cpt files.

slu
Thanks, this example is helpful.
Greg Harman