summaryrefslogtreecommitdiff
path: root/lisp/gnus
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-30 22:20:09 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-30 22:20:09 -0700
commitd0672f86c94e9dbf52e783e2bc4162b9cf3b5f44 (patch)
treee0e9fc7f479bce996d52c4356052480b3a088c56 /lisp/gnus
parentb9444d97feca73cb2a90559241bc79584692da54 (diff)
parentbbc6b304672eb229e6750692a1b4e83277ded115 (diff)
downloademacs-d0672f86c94e9dbf52e783e2bc4162b9cf3b5f44.tar.gz
emacs-d0672f86c94e9dbf52e783e2bc4162b9cf3b5f44.tar.bz2
emacs-d0672f86c94e9dbf52e783e2bc4162b9cf3b5f44.zip
Merge from trunk.
Diffstat (limited to 'lisp/gnus')
-rw-r--r--lisp/gnus/ChangeLog19
-rw-r--r--lisp/gnus/auth-source.el2
-rw-r--r--lisp/gnus/gnus-draft.el16
-rw-r--r--lisp/gnus/plstore.el107
4 files changed, 112 insertions, 32 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 88ba910912e..7d1e7ed7198 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -3,7 +3,24 @@
* nntp.el (nntp-record-command):
* gnus-util.el (gnus-message-with-timestamp-1):
Use format-time-string rather than decoding time stamps by hand.
- This is simpler and insulates the code from changes to time formats.
+ This is simpler and insulates the code from potential changes to
+ current-time format.
+
+2011-07-01 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * gnus-draft.el (gnus-draft-clear-marks): Mark deleted articles as read.
+
+2011-07-01 Daiki Ueno <ueno@unixuser.org>
+
+ * plstore.el (plstore-select-keys, plstore-encrypt-to): New variable.
+ (plstore-save): Support public key encryption.
+ (plstore--init-from-buffer): New function.
+ (plstore-open): Use it; fix error when opening a non-existent file.
+ (plstore-revert): Use plstore--init-from-buffer.
+
+2011-07-01 Daiki Ueno <ueno@unixuser.org>
+
+ * auth-source.el (auth-source-backend): Fix :initarg for data slot.
2011-06-30 Katsumi Yamaoka <yamaoka@jpl.org>
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 9391bf23d37..9d62d6a81c4 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -116,7 +116,7 @@ let-binding."
:type t
:custom string
:documentation "The backend protocol.")
- (data :initarg :arg
+ (data :initarg :data
:initform nil
:documentation "Internal backend data.")
(create-function :initarg :create-function
diff --git a/lisp/gnus/gnus-draft.el b/lisp/gnus/gnus-draft.el
index 1709b1c4a05..a2a4cd3e07d 100644
--- a/lisp/gnus/gnus-draft.el
+++ b/lisp/gnus/gnus-draft.el
@@ -325,10 +325,18 @@ If DONT-POP is nil, display the buffer after setting it up."
(error "The draft %s is under edit" file)))))
(defun gnus-draft-clear-marks ()
- (setq gnus-newsgroup-reads nil
- gnus-newsgroup-marked nil
- gnus-newsgroup-unreads
- (gnus-uncompress-range (gnus-active gnus-newsgroup-name))))
+ (setq gnus-newsgroup-marked nil
+ gnus-newsgroup-unreads (gnus-uncompress-range
+ (gnus-active gnus-newsgroup-name)))
+ ;; Mark articles except for deleted ones as unread.
+ (let (rest)
+ (dolist (article gnus-newsgroup-reads)
+ (when (and (consp article)
+ (eq (cdr article) gnus-canceled-mark))
+ (push article rest)
+ (setq gnus-newsgroup-unreads
+ (delq (car article) gnus-newsgroup-unreads))))
+ (setq gnus-newsgroup-reads (nreverse rest))))
(provide 'gnus-draft)
diff --git a/lisp/gnus/plstore.el b/lisp/gnus/plstore.el
index 392437d1dea..360388d002e 100644
--- a/lisp/gnus/plstore.el
+++ b/lisp/gnus/plstore.el
@@ -44,6 +44,40 @@
(require 'epg)
+(defgroup plstore nil
+ "Searchable, partially encrypted, persistent plist store"
+ :version "24.1"
+ :group 'files)
+
+(defcustom plstore-select-keys 'silent
+ "Control whether or not to pop up the key selection dialog.
+
+If t, always asks user to select recipients.
+If nil, query user only when `plstore-encrypt-to' is not set.
+If neither t nor nil, doesn't ask user. In this case, symmetric
+encryption is used."
+ :type '(choice (const :tag "Ask always" t)
+ (const :tag "Ask when recipients are not set" nil)
+ (const :tag "Don't ask" silent))
+ :group 'plstore)
+
+(defvar plstore-encrypt-to nil
+ "*Recipient(s) used for encrypting secret entries.
+May either be a string or a list of strings.")
+
+(put 'plstore-encrypt-to 'safe-local-variable
+ (lambda (val)
+ (or (stringp val)
+ (and (listp val)
+ (catch 'safe
+ (mapc (lambda (elt)
+ (unless (stringp elt)
+ (throw 'safe nil)))
+ val)
+ t)))))
+
+(put 'plstore-encrypt-to 'permanent-local t)
+
(defvar plstore-cache-passphrase-for-symmetric-encryption nil)
(defvar plstore-passphrase-alist nil)
@@ -107,35 +141,39 @@
(defun plstore-get-file (this)
(buffer-file-name (plstore--get-buffer this)))
+(defun plstore--init-from-buffer (plstore)
+ (goto-char (point-min))
+ (when (looking-at ";;; public entries")
+ (forward-line)
+ (plstore--set-alist plstore (read (point-marker)))
+ (forward-sexp)
+ (forward-char)
+ (when (looking-at ";;; secret entries")
+ (forward-line)
+ (plstore--set-encrypted-data plstore (read (point-marker))))
+ (plstore--merge-secret plstore)))
+
;;;###autoload
(defun plstore-open (file)
"Create a plstore instance associated with FILE."
- (let ((store (vector
- (find-file-noselect file)
- nil ;plist (plist)
- nil ;encrypted data (string)
- nil ;secret plist (plist)
- nil ;merged plist (plist)
- )))
- (plstore-revert store)
- store))
+ (with-current-buffer (find-file-noselect file)
+ ;; make the buffer invisible from user
+ (rename-buffer (format " plstore %s" (buffer-file-name)))
+ (let ((store (vector
+ (current-buffer)
+ nil ;plist (plist)
+ nil ;encrypted data (string)
+ nil ;secret plist (plist)
+ nil ;merged plist (plist)
+ )))
+ (plstore--init-from-buffer store)
+ store)))
(defun plstore-revert (plstore)
"Replace current data in PLSTORE with the file on disk."
(with-current-buffer (plstore--get-buffer plstore)
(revert-buffer t t)
- ;; make the buffer invisible from user
- (rename-buffer (format " plstore %s" (buffer-file-name)))
- (goto-char (point-min))
- (when (looking-at ";;; public entries\n")
- (forward-line)
- (plstore--set-alist plstore (read (point-marker)))
- (forward-sexp)
- (forward-char)
- (when (looking-at ";;; secret entries\n")
- (forward-line)
- (plstore--set-encrypted-data plstore (read (point-marker))))
- (plstore--merge-secret plstore))))
+ (plstore--init-from-buffer plstore)))
(defun plstore-close (plstore)
"Destroy a plstore instance PLSTORE."
@@ -304,20 +342,37 @@ SECRET-KEYS is a plist containing secret data."
"Save the contents of PLSTORE associated with a FILE."
(with-current-buffer (plstore--get-buffer plstore)
(erase-buffer)
- (insert ";;; public entries\n" (pp-to-string (plstore--get-alist plstore)))
+ (insert ";;; public entries -*- mode: emacs-lisp -*- \n"
+ (pp-to-string (plstore--get-alist plstore)))
(if (plstore--get-secret-alist plstore)
(let ((context (epg-make-context 'OpenPGP))
(pp-escape-newlines nil)
+ (recipients
+ (cond
+ ((listp plstore-encrypt-to) plstore-encrypt-to)
+ ((stringp plstore-encrypt-to) (list plstore-encrypt-to))))
cipher)
(epg-context-set-armor context t)
(epg-context-set-passphrase-callback
context
(cons #'plstore-passphrase-callback-function
plstore))
- (setq cipher (epg-encrypt-string context
- (pp-to-string
- (plstore--get-secret-alist plstore))
- nil))
+ (setq cipher (epg-encrypt-string
+ context
+ (pp-to-string
+ (plstore--get-secret-alist plstore))
+ (if (or (eq plstore-select-keys t)
+ (and (null plstore-select-keys)
+ (not (local-variable-p 'plstore-encrypt-to
+ (current-buffer)))))
+ (epa-select-keys
+ context
+ "Select recipents for encryption.
+If no one is selected, symmetric encryption will be performed. "
+ recipients)
+ (if plstore-encrypt-to
+ (epg-list-keys context recipients)))))
+ (goto-char (point-max))
(insert ";;; secret entries\n" (pp-to-string cipher))))
(save-buffer)))