From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Cc: Daiki Ueno <ueno@unixuser.org>
Subject: epg--status-GET-HIDDEN cleanup suggestion
Date: Sat, 16 Aug 2008 08:17:49 -0500 [thread overview]
Message-ID: <m2vdy16qv6.fsf@lifelogs.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: epg.el.patch --]
[-- Type: text/x-patch, Size: 4419 bytes --]
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 "? ")))))
next reply other threads:[~2008-08-16 13:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 13:17 Ted Zlatanov [this message]
2008-08-16 13:41 ` epg--status-GET-HIDDEN cleanup suggestion Daiki Ueno
2008-08-16 16:05 ` Ted Zlatanov
2008-08-18 1:16 ` Daiki Ueno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2vdy16qv6.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@gnu.org \
--cc=ueno@unixuser.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).