summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2010-10-06 14:02:39 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2010-10-06 14:02:39 +0000
commitfd9ba500f5f58549e0210a2334c38ba0916257d9 (patch)
treef48ac3770cf2620d10643b67e604c5ff88a20a46 /lisp
parent356242428b39c85760780f961ba40672d8e2d8b3 (diff)
downloademacs-fd9ba500f5f58549e0210a2334c38ba0916257d9.tar.gz
sieve-manage.el: Add authenticate function.
sieve-manage.el (sieve-manage-open): Use sieve-manage-default-port.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gnus/ChangeLog10
-rw-r--r--lisp/gnus/sieve-manage.el19
-rw-r--r--lisp/gnus/sieve.el9
3 files changed, 28 insertions, 10 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 08c5282728e..0ffc7599cba 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-06 Julien Danjou <julien@danjou.info>
+
+ * sieve-manage.el: Update example in `Commentary'.
+
+ * sieve.el (sieve-open-server): Use sieve-manage-authenticate.
+
+ * sieve-manage.el (sieve-manage-open): Use sieve-manage-default-port,
+ not 2000.
+ (sieve-manage-authenticate): Re-add function.
+
2010-10-06 Lars Magne Ingebrigtsen <larsi@gnus.org>
* shr.el (shr-insert): Get 'space transition right.
diff --git a/lisp/gnus/sieve-manage.el b/lisp/gnus/sieve-manage.el
index 370a53d4ac9..c542632a5a0 100644
--- a/lisp/gnus/sieve-manage.el
+++ b/lisp/gnus/sieve-manage.el
@@ -50,9 +50,11 @@
;;
;; and that's it. Example of a managesieve session in *scratch*:
;;
+;; (with-current-buffer (sieve-manage-open "mail.example.com")
+;; (sieve-manage-authenticate)
+;; (sieve-manage-listscripts))
;;
-;; (sieve-manage-listscripts my-buf)
-;; ("vacation" "testscript" ("splitmail") "badscript")
+;; => ((active . "main") "vacation")
;;
;; References:
;;
@@ -387,7 +389,7 @@ Optional argument AUTH indicates authenticator to use, see
If nil, chooses the best stream the server is capable of.
Optional argument BUFFER is buffer (buffer, or string naming buffer)
to work in."
- (setq buffer (or buffer (format " *sieve* %s:%d" server (or port 2000))))
+ (setq buffer (or buffer (format " *sieve* %s:%d" server (or port sieve-manage-default-port))))
(with-current-buffer (get-buffer-create buffer)
(mapc 'make-local-variable sieve-manage-local-variables)
(sieve-manage-disable-multibyte)
@@ -444,6 +446,17 @@ to work in."
(sieve-manage-erase)
buffer)))
+(defun sieve-manage-authenticate (&optional buffer)
+ "Authenticate on server in BUFFER.
+Return `sieve-manage-state' value."
+ (with-current-buffer (or buffer (current-buffer))
+ (if (eq sieve-manage-state 'nonauth)
+ (when (funcall (nth 2 (assq sieve-manage-auth
+ sieve-manage-authenticator-alist))
+ (current-buffer))
+ (setq sieve-manage-state 'auth))
+ sieve-manage-state)))
+
(defun sieve-manage-opened (&optional buffer)
"Return non-nil if connection to managesieve server in BUFFER is open.
If BUFFER is nil then the current buffer is used."
diff --git a/lisp/gnus/sieve.el b/lisp/gnus/sieve.el
index e988cb759de..ca181c2e7b3 100644
--- a/lisp/gnus/sieve.el
+++ b/lisp/gnus/sieve.el
@@ -320,17 +320,12 @@ Server : " server ":" (or port "2000") "
(insert "\n"))))
(defun sieve-open-server (server &optional port)
+ "Open SERVER (on PORT) and authenticate."
(with-current-buffer
;; open server
(set (make-local-variable 'sieve-manage-buffer)
(sieve-manage-open server))
- ;; authenticate
- (if (eq sieve-manage-state 'nonauth)
- (if (funcall (nth 2 (assq sieve-manage-auth
- sieve-manage-authenticator-alist))
- (current-buffer))
- (setq sieve-manage-state 'auth))
- (eq sieve-manage-state 'auth))))
+ (sieve-manage-authenticate)))
(defun sieve-refresh-scriptlist ()
(interactive)