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: Daiki Ueno
Subject: Re: pgg-encrypt is a pain in the neck
Date: Sun, 31 Dec 2006 23:13:24 +0900
User-agent: T-gnus/6.17.2 (based on No Gnus v0.2) EMIKO/1.14.1 (Choanoflagellata) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 EasyPG/0.0.9 MULE XEmacs/21.4 (patch 14) (Reasonable Discussion) (i686-pc-linux)

>>>>> In <address@hidden> 
>>>>>   Sascha Wilde <address@hidden> wrote:
> > There seems to be a disagreement about this.  Daiki Ueno told me that
> > PGG could do what Mailcrypt does; I found it cannot, and you say it
> > isn't supposed to.

> I can't speak for Daiki, but as I see it PGG on its own can't but
> together with message mode it can, so this might be what he meant.

It was my mistake that I answered to Richard's question with simply
"Yes".

What I meant was not "PGG's interactive commands behave exactly same as
Mailcrypt's interactive commands" but "things he wanted could be done
with PGG's interactive commands (with some basic commands)".  For
example, to encrypt a mail, people can do `C-x n n' to narrow to the
mail body and `M-x pgg-encrypt'.

However, I agree with that PGG's interactive commands sucks in usability.

> > Meanwhile, it is unfortunate that Emacs has most of what is needed to
> > do the job of Mailcrypt but fails to actually deliver that
> > functionality to the user.  I hope people will implement this, soon
> > after the release.

> I agree, and as Daiki wrote it shouldn't be to hard to do.

Here is the patch.  Though it might look not so trivial, it only changes
the interactive behavior of pgg-encrypt and pgg-decrypt so it should
bring no harm to other Lisp programs.

Index: lisp/pgg.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/pgg.el,v
retrieving revision 1.4
diff -c -r1.4 pgg.el
*** lisp/pgg.el 5 Sep 2006 08:17:35 -0000       1.4
--- lisp/pgg.el 31 Dec 2006 14:12:54 -0000
***************
*** 37,42 ****
--- 37,44 ----
  (eval-when-compile
    (require 'cl))
  
+ (require 'mail-utils)
+ 
  ;;; @ utility functions
  ;;;
  
***************
*** 367,373 ****
  
  If optional PASSPHRASE is not specified, it will be obtained from the
  passphrase cache or user."
!   (interactive (list (split-string (read-string "Recipients: ") "[ \t,]+")))
    (let* ((start (or start (point-min)))
         (end (or end (point-max)))
         (status (pgg-encrypt-region start end rcpts sign passphrase)))
--- 369,399 ----
  
  If optional PASSPHRASE is not specified, it will be obtained from the
  passphrase cache or user."
!   (interactive
!    (save-excursion
!      (let (recipients)
!        (goto-char (point-min))
!        (when (eq major-mode 'mail-mode)
!        (save-restriction
!          (narrow-to-region (point)
!                            (progn
!                              (search-forward mail-header-separator nil 0)
!                              (match-beginning 0)))
!          (setq recipients
!                (mail-strip-quoted-names
!                 (mapconcat #'identity
!                            (nconc (mail-fetch-field "to" nil nil t)
!                                   (mail-fetch-field "cc" nil nil t)
!                                   (mail-fetch-field "bcc" nil nil t))
!                            ","))))
!        (if recipients
!            (setq recipients (delete "" (split-string recipients "[ \t\n]+"))))
!        (goto-char (point-min))
!        (if (search-forward mail-header-separator nil t)
!            (forward-line)))
!        (list (or recipients
!                (split-string (read-string "Recipients: ") "[ \t,]+"))
!            nil (point) (point-max)))))
    (let* ((start (or start (point-min)))
         (end (or end (point-max)))
         (status (pgg-encrypt-region start end rcpts sign passphrase)))
***************
*** 400,412 ****
  
  If optional PASSPHRASE is not specified, it will be obtained from the
  passphrase cache or user."
!   (interactive "")
!   (let* ((start (or start (point-min)))
!        (end (or end (point-max)))
!        (status (pgg-decrypt-region start end passphrase)))
!     (when (interactive-p)
!       (pgg-display-output-buffer start end status))
!     status))
  
  ;;;###autoload
  (defun pgg-sign-region (start end &optional cleartext passphrase)
--- 426,455 ----
  
  If optional PASSPHRASE is not specified, it will be obtained from the
  passphrase cache or user."
!   (interactive)
!   (if (interactive-p)
!       (let (cipher status)
!       (goto-char (point-min))
!       (if (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
!           (setq start (match-beginning 0)
!                 end (re-search-forward "^-----END PGP MESSAGE-----$" nil t)))
!       (unless end
!         (error "No armor tail"))
!       (setq cipher (buffer-substring start end))
!       (with-temp-buffer
!         (insert cipher)
!         (setq status (pgg-decrypt-region (point-min) (point-max))))
!       (if status
!           (if (y-or-n-p "Replace text? ")
!               (let ((inhibit-read-only t)
!                     buffer-read-only)
!                 (pgg-situate-output start end))
!             (with-output-to-temp-buffer pgg-echo-buffer
!               (set-buffer standard-output)
!               (insert-buffer pgg-output-buffer)))
!         (pgg-display-error-buffer)))
!     (pgg-decrypt-region (or start (point-min)) (or end (point-max))
!                       passphrase)))
  
  ;;;###autoload
  (defun pgg-sign-region (start end &optional cleartext passphrase)

-- 
Daiki Ueno




reply via email to

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