aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2012-12-05 02:26:15 +0000
committerKatsumi Yamaoka2012-12-05 02:26:15 +0000
commit066f0e09bc17809beeb6b6c20e3032d0f4420795 (patch)
treec98318b906347a135d21c04d6202a6ce38688e3c
parent49596095d09227d828ffb6fed955ba0b660b4d92 (diff)
downloademacs-066f0e09bc17809beeb6b6c20e3032d0f4420795.tar.gz
emacs-066f0e09bc17809beeb6b6c20e3032d0f4420795.zip
gmm-util.el: Re-introduce gmm-flet using cl-letf
-rw-r--r--lisp/gnus/ChangeLog6
-rw-r--r--lisp/gnus/gmm-utils.el18
-rw-r--r--lisp/gnus/gnus-sync.el26
-rw-r--r--lisp/gnus/message.el10
4 files changed, 37 insertions, 23 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index af19f607f99..d3b66f4c8fd 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,11 @@
12012-12-05 Katsumi Yamaoka <yamaoka@jpl.org> 12012-12-05 Katsumi Yamaoka <yamaoka@jpl.org>
2 2
3 * gmm-utils.el (gmm-flet): Restore it using cl-letf.
4 * gnus-sync.el (gnus-sync-lesync-call)
5 * message.el (message-read-from-minibuffer): Use it.
6
72012-12-05 Katsumi Yamaoka <yamaoka@jpl.org>
8
3 * gmm-utils.el (gmm-flet): Remove. 9 * gmm-utils.el (gmm-flet): Remove.
4 * gnus-sync.el (gnus-sync-lesync-call) 10 * gnus-sync.el (gnus-sync-lesync-call)
5 * message.el (message-read-from-minibuffer): Don't use it. 11 * message.el (message-read-from-minibuffer): Don't use it.
diff --git a/lisp/gnus/gmm-utils.el b/lisp/gnus/gmm-utils.el
index 6a64dcff11b..ab42b149be3 100644
--- a/lisp/gnus/gmm-utils.el
+++ b/lisp/gnus/gmm-utils.el
@@ -417,7 +417,23 @@ coding-system."
417 (write-region start end filename append visit lockname)) 417 (write-region start end filename append visit lockname))
418 (write-region start end filename append visit lockname mustbenew))) 418 (write-region start end filename append visit lockname mustbenew)))
419 419
420;; `labels' got obsolete since Emacs 24.3. 420;; `flet' and `labels' got obsolete since Emacs 24.3.
421(defmacro gmm-flet (bindings &rest body)
422 "Make temporary overriding function definitions.
423This is an analogue of a dynamically scoped `let' that operates on
424the function cell of FUNCs rather than their value cell.
425
426\(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
427 (require 'cl)
428 (if (fboundp 'cl-letf)
429 `(cl-letf ,(mapcar (lambda (binding)
430 `((symbol-function ',(car binding))
431 (lambda ,@(cdr binding))))
432 bindings)
433 ,@body)
434 `(flet ,bindings ,@body)))
435(put 'gmm-flet 'lisp-indent-function 1)
436
421(defmacro gmm-labels (bindings &rest body) 437(defmacro gmm-labels (bindings &rest body)
422 "Make temporary function bindings. 438 "Make temporary function bindings.
423The bindings can be recursive and the scoping is lexical, but capturing 439The bindings can be recursive and the scoping is lexical, but capturing
diff --git a/lisp/gnus/gnus-sync.el b/lisp/gnus/gnus-sync.el
index 895a5e4d9a5..e2a71f0ee01 100644
--- a/lisp/gnus/gnus-sync.el
+++ b/lisp/gnus/gnus-sync.el
@@ -88,6 +88,7 @@
88(require 'gnus) 88(require 'gnus)
89(require 'gnus-start) 89(require 'gnus-start)
90(require 'gnus-util) 90(require 'gnus-util)
91(require 'gmm-utils)
91 92
92(defvar gnus-topic-alist) ;; gnus-group.el 93(defvar gnus-topic-alist) ;; gnus-group.el
93(eval-when-compile 94(eval-when-compile
@@ -176,21 +177,16 @@ and `gnus-topic-alist'. Also see `gnus-variable-list'."
176(defun gnus-sync-lesync-call (url method headers &optional kvdata) 177(defun gnus-sync-lesync-call (url method headers &optional kvdata)
177 "Make an access request to URL using KVDATA and METHOD. 178 "Make an access request to URL using KVDATA and METHOD.
178KVDATA must be an alist." 179KVDATA must be an alist."
179 (let ((orig-json-alist-p (symbol-function 'json-alist-p))) 180 (gmm-flet ((json-alist-p (list) (gnus-sync-json-alist-p list))) ; temp patch
180 (fset 'json-alist-p 181 (let ((url-request-method method)
181 (lambda (list) (gnus-sync-json-alist-p list))) ; temp patch 182 (url-request-extra-headers headers)
182 (unwind-protect 183 (url-request-data (if kvdata (json-encode kvdata) nil)))
183 (let ((url-request-method method) 184 (with-current-buffer (url-retrieve-synchronously url)
184 (url-request-extra-headers headers) 185 (let ((data (gnus-sync-lesync-parse)))
185 (url-request-data (if kvdata (json-encode kvdata) nil))) 186 (gnus-message 12 "gnus-sync-lesync-call: %s URL %s sent %S got %S"
186 (with-current-buffer (url-retrieve-synchronously url) 187 method url `((headers . ,headers) (data ,kvdata)) data)
187 (let ((data (gnus-sync-lesync-parse))) 188 (kill-buffer (current-buffer))
188 (gnus-message 189 data)))))
189 12 "gnus-sync-lesync-call: %s URL %s sent %S got %S"
190 method url `((headers . ,headers) (data ,kvdata)) data)
191 (kill-buffer (current-buffer))
192 data)))
193 (fset 'json-alist-p orig-json-alist-p))))
194 190
195(defun gnus-sync-lesync-PUT (url headers &optional data) 191(defun gnus-sync-lesync-PUT (url headers &optional data)
196 (gnus-sync-lesync-call url "PUT" headers data)) 192 (gnus-sync-lesync-call url "PUT" headers data))
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 03ffe2fb2eb..2171dcf3edc 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -8140,13 +8140,9 @@ regexp VARSTR."
8140 "Read from the minibuffer while providing abbrev expansion." 8140 "Read from the minibuffer while providing abbrev expansion."
8141 (if (fboundp 'mail-abbrevs-setup) 8141 (if (fboundp 'mail-abbrevs-setup)
8142 (let ((minibuffer-setup-hook 'mail-abbrevs-setup) 8142 (let ((minibuffer-setup-hook 'mail-abbrevs-setup)
8143 (minibuffer-local-map message-minibuffer-local-map) 8143 (minibuffer-local-map message-minibuffer-local-map))
8144 (orig-m-a-i-e-h-p (symbol-function 8144 (gmm-flet ((mail-abbrev-in-expansion-header-p nil t))
8145 'mail-abbrev-in-expansion-header-p))) 8145 (read-from-minibuffer prompt initial-contents)))
8146 (fset 'mail-abbrev-in-expansion-header-p (lambda (&rest args) t))
8147 (unwind-protect
8148 (read-from-minibuffer prompt initial-contents)
8149 (fset 'mail-abbrev-in-expansion-header-p orig-m-a-i-e-h-p)))
8150 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook) 8146 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook)
8151 (minibuffer-local-map message-minibuffer-local-map)) 8147 (minibuffer-local-map message-minibuffer-local-map))
8152 (read-string prompt initial-contents)))) 8148 (read-string prompt initial-contents))))