emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] url-cache (url-store-in-cache): Make `buff' argument really opti


From: Julien Danjou
Subject: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
Date: Wed, 8 Sep 2010 14:51:00 +0200

Currently, `buff' is marked as optional, but if it is set to nil, the
function does nothing.

Signed-off-by: Julien Danjou <address@hidden>
---
 lisp/url/ChangeLog    |    5 +++++
 lisp/url/url-cache.el |   13 +++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index e3f76e7..2a69b48 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-08  Julien Danjou  <address@hidden>
+
+       * url-cache (url-store-in-cache): Make `buff' argument really
+       optional by using (current-buffer) if `buff' is nil.
+
 2010-07-27  Michael Albinus  <address@hidden>
 
        * url-http (url-http-parse-headers): Disable file name handlers at
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 71841c9..ebd9f61 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -62,14 +62,11 @@ FILE can be created or overwritten."
 ;;;###autoload
 (defun url-store-in-cache (&optional buff)
   "Store buffer BUFF in the cache."
-  (if (not (and buff (get-buffer buff)))
-      nil
-    (save-current-buffer
-      (and buff (set-buffer buff))
-      (let* ((fname (url-cache-create-filename (url-view-url t))))
-       (if (url-cache-prepare fname)
-           (let ((coding-system-for-write 'binary))
-             (write-region (point-min) (point-max) fname nil 5)))))))
+    (with-current-buffer (get-buffer (or buff (current-buffer)))
+      (let ((fname (url-cache-create-filename (url-view-url t))))
+        (if (url-cache-prepare fname)
+            (let ((coding-system-for-write 'binary))
+              (write-region (point-min) (point-max) fname nil 5))))))
 
 ;;;###autoload
 (defun url-is-cached (url)
-- 
1.7.1




reply via email to

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