emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105461: Bug fix for finding coding s


From: Richard Stallman
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105461: Bug fix for finding coding system. New COPY-FUNCTION feature
Date: Mon, 15 Aug 2011 21:40:26 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105461
committer: Richard Stallman <address@hidden>
branch nick: trunk
timestamp: Mon 2011-08-15 21:40:26 -0400
message:
  Bug fix for finding coding system.  New COPY-FUNCTION feature
  for epa-decrypt-region.
modified:
  lisp/ChangeLog
  lisp/epa.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-08-15 16:10:39 +0000
+++ b/lisp/ChangeLog    2011-08-16 01:40:26 +0000
@@ -1,3 +1,9 @@
+2011-08-16  Richard Stallman  <address@hidden>
+
+       * epa.el (epa-decrypt-region): New arg COPY-FUNCTION.
+       (epa--find-coding-system-for-mime-charset): Fix the non-xemacs case.
+       (epa-decrypt-armor-in-region): Make error message clearer.
+
 2011-08-15  Stefan Monnier  <address@hidden>
 
        * minibuffer.el (completion-pcm--merge-completions): Don't merge "a1b"

=== modified file 'lisp/epa.el'
--- a/lisp/epa.el       2011-08-12 03:30:18 +0000
+++ b/lisp/epa.el       2011-08-16 01:40:26 +0000
@@ -803,10 +803,12 @@
             (file-name-nondirectory cipher))))
 
 ;;;###autoload
-(defun epa-decrypt-region (start end)
+(defun epa-decrypt-region (start end &optional copy-function)
   "Decrypt the current region between START and END.
+If COPY-FUNCTION is non-nil, call it to copy the current buffer
+into some other buffer for the output; it should return that buffer.
 
-Don't use this command in Lisp programs!
+Be careful about using this command in Lisp programs!
 Since this function operates on regions, it does some tricks such
 as coding-system detection and unibyte/multibyte conversion.  If
 you are sure how the data in the region should be treated, you
@@ -844,10 +846,17 @@
            (delete-region start end)
            (goto-char start)
            (insert plain))
-       (with-output-to-temp-buffer "*Temp*"
-         (set-buffer standard-output)
-         (insert plain)
-         (epa-info-mode)))
+       (if copy-function
+           (with-current-buffer (funcall copy-function)
+             (let ((inhibit-read-only t)
+                   buffer-read-only)
+               (delete-region start end)
+               (goto-char start)
+               (insert plain)))
+         (with-output-to-temp-buffer "*Temp*"
+           (set-buffer standard-output)
+             (insert plain)
+             (epa-info-mode))))
       (if (epg-context-result-for context 'verify)
          (epa-display-info (epg-verify-result-to-string
                             (epg-context-result-for context 'verify)))))))
@@ -856,12 +865,13 @@
   (if (featurep 'xemacs)
       (if (fboundp 'find-coding-system)
          (find-coding-system mime-charset))
+    ;; Find the first coding system which corresponds to MIME-CHARSET.
     (let ((pointer (coding-system-list)))
       (while (and pointer
-                 (eq (coding-system-get (car pointer) 'mime-charset)
-                     mime-charset))
+                 (not (eq (coding-system-get (car pointer) 'mime-charset)
+                          mime-charset)))
        (setq pointer (cdr pointer)))
-      pointer)))
+      (car pointer))))
 
 ;;;###autoload
 (defun epa-decrypt-armor-in-region (start end)
@@ -880,7 +890,7 @@
                armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
                                             nil t))
          (unless armor-end
-           (error "No armor tail"))
+           (error "Encryption armor beginning has no matching end"))
          (goto-char armor-start)
          (let ((coding-system-for-read
                 (or coding-system-for-read


reply via email to

[Prev in Thread] Current Thread [Next in Thread]