[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
epg--status-GET-HIDDEN cleanup suggestion
From: |
Ted Zlatanov |
Subject: |
epg--status-GET-HIDDEN cleanup suggestion |
Date: |
Sat, 16 Aug 2008 08:17:49 -0500 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (darwin) |
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
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 "? ")))))
- epg--status-GET-HIDDEN cleanup suggestion,
Ted Zlatanov <=