From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daiki Ueno Newsgroups: gmane.emacs.devel Subject: Re: pgg-encrypt is a pain in the neck Date: Sun, 31 Dec 2006 23:13:24 +0900 Message-ID: <59af811b-d38b-4c25-9cbd-9b3f836549ee@well-done.deisui.org> References: <6662a3b9-1148-4aa0-bd2d-29a67be38d76@well-done.deisui.org> <5a520e06-4ee3-4c4f-9345-d49a666516f9@well-done.deisui.org> <7f60c21d-2f66-4c4b-9abb-e377ca24a153@well-done.deisui.org> <844cd50a-ec18-4b09-a057-35bdfb5173fd@well-done.deisui.org> <8ba25607-9381-4a27-ae53-8b0f3ccc3ac1@well-done.deisui.org> <366fa6ab-42a0-4df5-a17f-4ac3d1744d78@well-done.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1167574432 20247 80.91.229.12 (31 Dec 2006 14:13:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 31 Dec 2006 14:13:52 +0000 (UTC) Cc: emacs-devel@gnu.org, rms@gnu.org, reinersteib+gmane@imap.cc Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 31 15:13:50 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H11Rc-0001Kr-Ki for ged-emacs-devel@m.gmane.org; Sun, 31 Dec 2006 15:13:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H11Rb-0001WU-U4 for ged-emacs-devel@m.gmane.org; Sun, 31 Dec 2006 09:13:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H11RN-0001Uy-GY for emacs-devel@gnu.org; Sun, 31 Dec 2006 09:13:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H11RM-0001UW-PY for emacs-devel@gnu.org; Sun, 31 Dec 2006 09:13:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H11RM-0001UJ-HM for emacs-devel@gnu.org; Sun, 31 Dec 2006 09:13:32 -0500 Original-Received: from [210.231.96.69] (helo=localhost) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H11RK-00011P-B2; Sun, 31 Dec 2006 09:13:31 -0500 Original-Received: from localhost ([127.0.0.1] helo=well-done.deisui.org) by localhost with esmtp (Exim 4.63) (envelope-from ) id 1H11RE-0004W8-VH; Sun, 31 Dec 2006 23:13:25 +0900 Original-To: Sascha Wilde X-Attribution: DU Mail-Copies-To: poster In-Reply-To: (Sascha Wilde's message of "Sun, 31 Dec 2006 13:54:17 +0100") 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) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64564 Archived-At: >>>>> In >>>>> Sascha Wilde 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