aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaiki Ueno2012-12-28 12:51:20 +0900
committerDaiki Ueno2012-12-28 12:51:20 +0900
commit23bd348c3f3c848957088950df797d49794f7667 (patch)
tree24d61bfbe149087c214cc5654c60297a062e8183
parent7456e13fa946233d1b4f0beb8371962de5012265 (diff)
downloademacs-23bd348c3f3c848957088950df797d49794f7667.tar.gz
emacs-23bd348c3f3c848957088950df797d49794f7667.zip
epg: Support pinentry-curses
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/epg.el38
2 files changed, 46 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 34cb50bb44c..c4d884a5010 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12012-12-28 Daiki Ueno <ueno@gnu.org>
2
3 * epg.el: Support pinentry-curses.
4 Suggested by Werner Koch in
5 <http://lists.gnu.org/archive/html/emacs-devel/2007-02/msg00755.html>.
6 (epg-agent-file, epg-agent-mtime): New variable.
7 (epg--start): Record the modified time of gpg-agent socket file,
8 to restore Emacs frame after pinentry-curses termination.
9 (epg-wait-for-completion): Restore Emacs frame here.
10
12012-12-27 Juri Linkov <juri@jurta.org> 112012-12-27 Juri Linkov <juri@jurta.org>
2 12
3 * info.el (Info-file-completions): New variable. 13 * info.el (Info-file-completions): New variable.
diff --git a/lisp/epg.el b/lisp/epg.el
index 280c24616f2..5fb8f809aa9 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -37,6 +37,8 @@
37(defvar epg-key-id nil) 37(defvar epg-key-id nil)
38(defvar epg-context nil) 38(defvar epg-context nil)
39(defvar epg-debug-buffer nil) 39(defvar epg-debug-buffer nil)
40(defvar epg-agent-file nil)
41(defvar epg-agent-mtime nil)
40 42
41;; from gnupg/include/cipher.h 43;; from gnupg/include/cipher.h
42(defconst epg-cipher-algorithm-alist 44(defconst epg-cipher-algorithm-alist
@@ -1156,7 +1158,28 @@ This function is for internal use only."
1156 process-connection-type 1158 process-connection-type
1157 (orig-mode (default-file-modes)) 1159 (orig-mode (default-file-modes))
1158 (buffer (generate-new-buffer " *epg*")) 1160 (buffer (generate-new-buffer " *epg*"))
1159 process) 1161 process
1162 terminal-name
1163 agent-file
1164 (agent-mtime '(0 0 0 0)))
1165 ;; Set GPG_TTY and TERM for pinentry-curses. Note that we can't
1166 ;; use `terminal-name' here to get the real pty name for the child
1167 ;; process, though /dev/fd/0" is not portable.
1168 (with-temp-buffer
1169 (when (= (call-process "tty" "/dev/fd/0" t) 0)
1170 (delete-backward-char 1)
1171 (setq terminal-name (buffer-string))))
1172 (when terminal-name
1173 (setenv "GPG_TTY" terminal-name)
1174 (setenv "TERM" "xterm"))
1175 ;; Record modified time of gpg-agent socket to restore the Emacs
1176 ;; frame on text terminal in `epg-wait-for-completion'.
1177 ;; See
1178 ;; <http://lists.gnu.org/archive/html/emacs-devel/2007-02/msg00755.html>
1179 ;; for more details.
1180 (when (and agent-info (string-match "\\(.*\\):[0-9]+:[0-9]+" agent-info))
1181 (setq agent-file (match-string 1 agent-info)
1182 agent-mtime (or (nth 5 (file-attributes agent-file)) '(0 0 0 0))))
1160 (if epg-debug 1183 (if epg-debug
1161 (save-excursion 1184 (save-excursion
1162 (unless epg-debug-buffer 1185 (unless epg-debug-buffer
@@ -1185,7 +1208,11 @@ This function is for internal use only."
1185 (make-local-variable 'epg-key-id) 1208 (make-local-variable 'epg-key-id)
1186 (setq epg-key-id nil) 1209 (setq epg-key-id nil)
1187 (make-local-variable 'epg-context) 1210 (make-local-variable 'epg-context)
1188 (setq epg-context context)) 1211 (setq epg-context context)
1212 (make-local-variable 'epg-agent-file)
1213 (setq epg-agent-file agent-file)
1214 (make-local-variable 'epg-agent-mtime)
1215 (setq epg-agent-mtime agent-mtime))
1189 (unwind-protect 1216 (unwind-protect
1190 (progn 1217 (progn
1191 (set-default-file-modes 448) 1218 (set-default-file-modes 448)
@@ -1262,6 +1289,13 @@ This function is for internal use only."
1262 (accept-process-output (epg-context-process context) 1)) 1289 (accept-process-output (epg-context-process context) 1))
1263 ;; This line is needed to run the process-filter right now. 1290 ;; This line is needed to run the process-filter right now.
1264 (sleep-for 0.1) 1291 (sleep-for 0.1)
1292 ;; Restore Emacs frame on text terminal, when pinentry-curses has terminated.
1293 (if (with-current-buffer (process-buffer (epg-context-process context))
1294 (and epg-agent-file
1295 (> (float-time (or (nth 5 (file-attributes epg-agent-file))
1296 '(0 0 0 0)))
1297 (float-time epg-agent-mtime))))
1298 (redraw-frame))
1265 (epg-context-set-result-for 1299 (epg-context-set-result-for
1266 context 'error 1300 context 'error
1267 (nreverse (epg-context-result-for context 'error)))) 1301 (nreverse (epg-context-result-for context 'error))))