emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pgg-encrypt is a pain in the neck


From: Richard Stallman
Subject: Re: pgg-encrypt is a pain in the neck
Date: Sun, 31 Dec 2006 17:13:20 -0500

    (defun mail-narrow-to-body ()
      "Narrow to mail body, excluding mail headers."
      (goto-char (point-min))
      (narrow-to-region
       (progn
         (mail-text)
         (point))
       ;; Or (cf. `message-goto-body') ...
       ;; (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
       ;;  (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t))
       (point-max)))

    (defun mail-encrypt-body ()
      (interactive)
      (save-excursion
        (save-restriction
          (mail-narrow-to-body)
          (call-interactively 'pgg-encrypt))))

This looks like a good start.  However, instead
of using call-interactively to call pgg-encrypt, it should
read the argument itself, and supply a default based on
the addresses in the message.  You can find the code
to get those addresses in sendmail-send-it.

I think something similar is needed for pgg-sign,
so as to will sign just the message body and not the headers.

    (defun mail-decrypt-body (&optional passphrase)
      (interactive)
      (save-excursion
        (save-restriction
          (mail-narrow-to-body)
          (if (apply 'pgg-decrypt-region (point-min) (point-max) passphrase)
              (pop-to-buffer pgg-output-buffer)
            (pgg-display-error-buffer)))))

This would work fine in Mail mode, but it also needs to handle Rmail
mode.  Decrypting is done once in a while in Mail mode, but Rmail mode
is where it is usually done.

Daiki's code for decryption does more of the right thing.  That could
be put into a command called mail-decrypt, to avoid changing pgg
itself.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]