Save excursion.
authorueno <ueno>
Sun, 31 Dec 2006 02:42:32 +0000 (02:42 +0000)
committerueno <ueno>
Sun, 31 Dec 2006 02:42:32 +0000 (02:42 +0000)
epa.el

diff --git a/epa.el b/epa.el
index 39ad100..f999ace 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -911,7 +911,7 @@ If no one is selected, default secret key is used.  "
 
 Don't use this command in Lisp programs!"
   (interactive
-   (progn
+   (save-excursion
      (goto-char (point-min))
      (if (and (or (eq major-mode 'mail-mode)
                  (eq (derived-mode-class major-mode) 'mail-mode))
@@ -982,45 +982,47 @@ If no one is selected, symmetric encryption will be performed.  "))))
 
 Don't use this command in Lisp programs!"
   (interactive
-   (let (recipients)
-     (goto-char (point-min))
-     (when (or (eq major-mode 'mail-mode)
-              (eq (derived-mode-class major-mode) 'mail-mode))
-       (save-restriction
-        (narrow-to-region (point)
-                          (progn
-                            (search-forward mail-header-separator nil 0)
-                            (match-beginning 0)))
-        (setq recipients
-              (mail-strip-quoted-names
-               (mapconcat #'identity
-                          (nconc (mail-fetch-field "to" nil nil t)
-                                 (mail-fetch-field "cc" nil nil t)
-                                 (mail-fetch-field "bcc" nil nil t))
-                          ","))))
-       (if recipients
-          (setq recipients (delete "" (split-string recipients "[ \t\n]+"))))
+   (save-excursion
+     (let (recipients)
        (goto-char (point-min))
-       (if (search-forward mail-header-separator nil t)
-          (forward-line)))
-     (setq epa-last-coding-system-specified
-          (or coding-system-for-write
-              (epa--select-safe-coding-system (point) (point-max))))
-     (list (point) (point-max)
-          (if current-prefix-arg
-              (epa-select-keys
-               (epg-make-context epa-protocol)
-               "Select recipients for encryption.
+       (when (or (eq major-mode 'mail-mode)
+                (eq (derived-mode-class major-mode) 'mail-mode))
+        (save-restriction
+          (narrow-to-region (point)
+                            (progn
+                              (search-forward mail-header-separator nil 0)
+                              (match-beginning 0)))
+          (setq recipients
+                (mail-strip-quoted-names
+                 (mapconcat #'identity
+                            (nconc (mail-fetch-field "to" nil nil t)
+                                   (mail-fetch-field "cc" nil nil t)
+                                   (mail-fetch-field "bcc" nil nil t))
+                            ","))))
+        (if recipients
+            (setq recipients (delete "" (split-string recipients "[ \t\n]+"))))
+        (goto-char (point-min))
+        (if (search-forward mail-header-separator nil t)
+            (forward-line)))
+       (setq epa-last-coding-system-specified
+            (or coding-system-for-write
+                (epa--select-safe-coding-system (point) (point-max))))
+       (list (point) (point-max)
+            (if current-prefix-arg
+                (epa-select-keys
+                 (epg-make-context epa-protocol)
+                 "Select recipients for encryption.
 If no one is selected, symmetric encryption will be performed.  "
-               recipients)
-            (if recipients
-                (delq nil
-                      (apply #'nconc
-                             (mapcar
-                              (lambda (recipient)
-                                (epg-list-keys (epg-make-context epa-protocol)
-                                               (concat "<" recipient ">")))
-                              recipients))))))))
+                 recipients)
+              (if recipients
+                  (delq nil
+                        (apply #'nconc
+                               (mapcar
+                                (lambda (recipient)
+                                  (epg-list-keys
+                                   (epg-make-context epa-protocol)
+                                   (concat "<" recipient ">")))
+                                recipients)))))))))
   (epa-encrypt-region start end recipients))
 
 ;;;###autoload