From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: epg--status-GET-HIDDEN cleanup suggestion Date: Sat, 16 Aug 2008 08:17:49 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1218892705 14652 80.91.229.12 (16 Aug 2008 13:18:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Aug 2008 13:18:25 +0000 (UTC) Cc: Daiki Ueno To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 16 15:19:17 2008 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 1KULgX-0005mn-EL for ged-emacs-devel@m.gmane.org; Sat, 16 Aug 2008 15:19:14 +0200 Original-Received: from localhost ([127.0.0.1]:49444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KULfZ-000255-Oy for ged-emacs-devel@m.gmane.org; Sat, 16 Aug 2008 09:18:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KULfU-00023D-IU for emacs-devel@gnu.org; Sat, 16 Aug 2008 09:18:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KULfQ-0001xL-Eg for emacs-devel@gnu.org; Sat, 16 Aug 2008 09:18:07 -0400 Original-Received: from [199.232.76.173] (port=48439 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KULfQ-0001xI-8x for emacs-devel@gnu.org; Sat, 16 Aug 2008 09:18:04 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:53376 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KULfP-0001va-Cz for emacs-devel@gnu.org; Sat, 16 Aug 2008 09:18:04 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KULfJ-0000k6-6f for emacs-devel@gnu.org; Sat, 16 Aug 2008 13:17:57 +0000 Original-Received: from c-68-60-254-123.hsd1.il.comcast.net ([68.60.254.123]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Aug 2008 13:17:57 +0000 Original-Received: from tzz by c-68-60-254-123.hsd1.il.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Aug 2008 13:17:57 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 133 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-68-60-254-123.hsd1.il.comcast.net X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (darwin) Cancel-Lock: sha1:nO3vjKvCiU+CyZYq03mN7aofRk8= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:102528 Archived-At: --=-=-= The function epg--status-GET-HIDDEN in epg.el had lots of repetition, so I cleaned it up a little with a let*. I don't know the protocol for comitting these cleanups, so I offer the patch for review. It works for me. Thanks Ted --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=epg.el.patch Index: epg.el =================================================================== RCS file: /sources/emacs/emacs/lisp/epg.el,v retrieving revision 1.6 diff -c -r1.6 epg.el *** epg.el 6 May 2008 07:57:34 -0000 1.6 --- epg.el 16 Aug 2008 13:14:25 -0000 *************** *** 1228,1282 **** (defun epg--status-GET_HIDDEN (context string) (when (and epg-key-id (string-match "\\`passphrase\\." string)) ! (unless (epg-context-passphrase-callback context) ! (error "passphrase-callback not set")) ! (let (inhibit-quit ! passphrase ! passphrase-with-new-line ! encoded-passphrase-with-new-line) ! (unwind-protect ! (condition-case nil ! (progn ! (setq passphrase ! (funcall ! (if (consp (epg-context-passphrase-callback context)) ! (car (epg-context-passphrase-callback context)) ! (epg-context-passphrase-callback context)) ! context ! epg-key-id ! (if (consp (epg-context-passphrase-callback context)) ! (cdr (epg-context-passphrase-callback context))))) ! (when passphrase ! (setq passphrase-with-new-line (concat passphrase "\n")) ! (epg--clear-string passphrase) ! (setq passphrase nil) ! (if epg-passphrase-coding-system ! (progn ! (setq encoded-passphrase-with-new-line ! (epg--encode-coding-string ! passphrase-with-new-line ! (coding-system-change-eol-conversion ! epg-passphrase-coding-system 'unix))) ! (epg--clear-string passphrase-with-new-line) ! (setq passphrase-with-new-line nil)) ! (setq encoded-passphrase-with-new-line ! passphrase-with-new-line ! passphrase-with-new-line nil)) ! (process-send-string (epg-context-process context) ! encoded-passphrase-with-new-line))) ! (quit ! (epg-context-set-result-for ! context 'error ! (cons '(quit) ! (epg-context-result-for context 'error))) ! (delete-process (epg-context-process context)))) ! (if passphrase ! (epg--clear-string passphrase)) ! (if passphrase-with-new-line ! (epg--clear-string passphrase-with-new-line)) ! (if encoded-passphrase-with-new-line ! (epg--clear-string encoded-passphrase-with-new-line)))))) ! (defun epg--prompt-GET_BOOL (context string) (let ((entry (assoc string epg-prompt-alist))) (y-or-n-p (if entry (cdr entry) (concat string "? "))))) --- 1228,1278 ---- (defun epg--status-GET_HIDDEN (context string) (when (and epg-key-id (string-match "\\`passphrase\\." string)) ! (let* ((context-callback (epg-context-passphrase-callback context)) ! (callback (or (car-safe context-callback) context-callback)) ! (file (cdr-safe context-callback))) ! (unless context-callback ! (error "passphrase-callback not set")) ! (let (inhibit-quit ! passphrase ! passphrase-with-new-line ! encoded-passphrase-with-new-line) ! (unwind-protect ! (condition-case nil ! (progn ! (setq passphrase ! (funcall callback context epg-key-id file)) ! (when passphrase ! (setq passphrase-with-new-line (concat passphrase "\n")) ! (epg--clear-string passphrase) ! (setq passphrase nil) ! (if epg-passphrase-coding-system ! (progn ! (setq encoded-passphrase-with-new-line ! (epg--encode-coding-string ! passphrase-with-new-line ! (coding-system-change-eol-conversion ! epg-passphrase-coding-system 'unix))) ! (epg--clear-string passphrase-with-new-line) ! (setq passphrase-with-new-line nil)) ! (setq encoded-passphrase-with-new-line ! passphrase-with-new-line ! passphrase-with-new-line nil)) ! (process-send-string (epg-context-process context) ! encoded-passphrase-with-new-line))) ! (quit ! (epg-context-set-result-for ! context 'error ! (cons '(quit) ! (epg-context-result-for context 'error))) ! (delete-process (epg-context-process context)))) ! (if passphrase ! (epg--clear-string passphrase)) ! (if passphrase-with-new-line ! (epg--clear-string passphrase-with-new-line)) ! (if encoded-passphrase-with-new-line ! (epg--clear-string encoded-passphrase-with-new-line))))))) ! (defun epg--prompt-GET_BOOL (context string) (let ((entry (assoc string epg-prompt-alist))) (y-or-n-p (if entry (cdr entry) (concat string "? "))))) --=-=-=--