Update FSF's address in GPL notices.
[elisp/semi.git] / pgg-gpg.el
index 5ba57c4..6826184 100644 (file)
@@ -20,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Code:
 
            (luna-make-entity 'pgg-scheme-gpg))))
 
 (defun pgg-gpg-process-region (start end passphrase program args)
-  (let* ((output-file-name
-         (concat temporary-file-directory (make-temp-name "pgg-output")))
+  (let* ((output-file-name (make-temp-file
+                           (expand-file-name "pgg-output"
+                                             temporary-file-directory)))
         (args
          `("--status-fd" "2"
            ,@(if passphrase '("--passphrase-fd" "0"))
+           "--yes" ; overwrite
            "--output" ,output-file-name
            ,@pgg-gpg-extra-args ,@args))
         (output-buffer pgg-output-buffer)
         (errors-buffer pgg-errors-buffer)
-        (orig-mode (default-file-modes))
         (process-connection-type nil)
         process status exit-status)
     (with-current-buffer (get-buffer-create errors-buffer)
@@ -74,7 +75,6 @@
       (erase-buffer))
     (unwind-protect
        (progn
-         (set-default-file-modes 448)
          (let ((coding-system-for-write 'binary))
            (setq process
                  (apply #'start-process "*GnuPG*" errors-buffer
       (if (and process (eq 'run (process-status process)))
          (interrupt-process process))
       (if (file-exists-p output-file-name)
-         (delete-file output-file-name))
-      (set-default-file-modes orig-mode))))
+         (delete-file output-file-name)))))
 
 (defun pgg-gpg-possibly-cache-passphrase (passphrase)
   (if (and pgg-cache-passphrase
     (with-temp-buffer
       (apply #'call-process pgg-gpg-program nil t nil args)
       (goto-char (point-min))
-      (if (re-search-forward "^\\(sec\\|pub\\):"  nil t)
-         (substring
-          (nth 3 (split-string
-                  (buffer-substring (match-end 0)
-                                    (progn (end-of-line)(point)))
-                  ":")) 8)))))
+      (if (re-search-forward "^\\(sec\\|pub\\):[^:]*:[^:]*:[^:]*:\\([^:]*\\)"
+                            nil t)
+         (substring (match-string 2) 8)))))
 
 (luna-define-method pgg-scheme-encrypt-region ((scheme pgg-scheme-gpg)
                                               start end recipients)