Subject: Re: bug#12117: read-passwd deletes prompt

From: Juri Linkov <[email-masked]>
Date: Tue, 07 Aug 2012 03:04:17 +0300

> Hmm... I guess the problem is even more general: any minibuffer input
> during insert-file-contents will suffer from it (granted, there usually
> isn't much minibuffer input during such calls, luckily).
>
> Maybe read-from-minibuffer should let-bind inhibit-read-only to nil?
> That sounds ugly, tho.

Since there is not much minibuffer input during insert-file-contents
(one is known at the moment) then perhaps it would be safer to fix
just these places specific to insert-file-contents:

=== modified file 'lisp/epa.el'
--- lisp/epa.el	2012-06-08 16:39:49 +0000
+++ lisp/epa.el	2012-08-07 00:01:14 +0000
@@ -589,6 +589,10 @@ (defun epa-display-verify-result (verify
 (make-obsolete 'epa-display-verify-result 'epa-display-info "23.1")
 
 (defun epa-passphrase-callback-function (context key-id handback)
+  ;; Bind `inhibit-read-only' to nil because `find-file-noselect-1' binds
+  ;; it to t (for `insert-file-contents') that allows the user to delete
+  ;; characters in the read-only minibuffer prompt in `read-passwd'.
+  (let ((inhibit-read-only nil))
   (if (eq key-id 'SYM)
       (read-passwd
        (format "Passphrase for symmetric encryption%s: "
@@ -603,7 +607,7 @@ (defun epa-passphrase-callback-function
        (let ((entry (assoc key-id epg-user-id-alist)))
 	 (if entry
 	     (format "Passphrase for %s %s: " key-id (cdr entry))
-	   (format "Passphrase for %s: " key-id)))))))
+	     (format "Passphrase for %s: " key-id))))))))
 
 (defun epa-progress-callback-function (_context what _char current total
 					       handback)